TokenLab

檔案與批次

檢索批次

檢索批次的當前狀態、計數和結果文件。

GET
/v1/batches/{batch_id}

概述

此端點是 TokenLab 的 OpenAI 兼容批次 API 的一部分。批次作業使用上傳的 JSONL 文件,異步運行,並可以稍後返回輸出/錯誤文件。

注意事項

  • 批次輸入文件必須使用 purpose=batch。
  • completion_window 目前為 24h。
  • 輸出順序不保證;始終通過 custom_id 匹配。
  • 批次項目內不支持串流。

範例

請求

cURL
curl -X GET "https://api.tokenlab.sh/v1/batches/batch_abc123" \
  -H "Authorization: Bearer sk-your-api-key"

請求 / 回應

使用上方的互動式 OpenAPI 面板以獲取確切的架構。

操作提示

  • 使用 custom_id 進行冪等的下游對帳。
  • 只有在工作者完成批次後,才會期望 output_file_id 和 error_file_id。

回應範例

回應

200 OK
{
  "id": "batch_abc123",
  "object": "batch",
  "status": "completed",
  "input_file_id": "file_abc123",
  "output_file_id": "file_out123",
  "error_file_id": "file_err123",
  "request_counts": { "total": 100, "completed": 98, "failed": 2 }
}

重要欄位

request_countsobject
總請求數、成功數、失敗數和取消數。
output_file_idstring|null
供相關 API 使用的檔案識別符。
error_file_idstring|null
供相關 API 使用的檔案識別符。

授權

BearerAuth
AuthorizationBearer <token>

API Key 驗證。請在 Dashboard > API > API Keys 建立或管理 API 金鑰。

位置: header

路徑參數

batch_id*string

回應

application/json

application/json