檔案與批次
建立批次
從上傳的輸入檔案創建一個與OpenAI兼容的批次作業。
概述
此端點是TokenLab的與OpenAI兼容的批次API的一部分。批次作業使用上傳的JSONL檔案,異步運行,並可以在稍後返回輸出/錯誤檔案。
注意事項
- 批次輸入檔案必須使用
purpose=batch。 completion_window目前為24h。- 輸出順序不保證;始終通過
custom_id進行匹配。 - 批次項目內不支持串流。
- 支援的批次項目端點為
/v1/chat/completions和/v1/embeddings,不支援/v1/responses。
請求
curl -X POST "https://api.tokenlab.sh/v1/batches" \
-H "Authorization: Bearer sk-your-api-key" \
-H "Content-Type: application/json" \
-d '{
"input_file_id": "file_abc123",
"endpoint": "/v1/chat/completions",
"completion_window": "24h"
}'請求 / 回應
使用上方的互動式OpenAPI面板以獲取確切的架構。
操作提示
- 使用
custom_id進行冪等的下游對帳。 - 只有在工作者完成批次後,才會期望
output_file_id和error_file_id。
回應
{
"id": "batch_abc123",
"object": "batch",
"endpoint": "/v1/chat/completions",
"input_file_id": "file_abc123",
"completion_window": "24h",
"status": "validating",
"output_file_id": null,
"error_file_id": null,
"created_at": 1706000000
}重要欄位
idstring
用於後續呼叫和支援排障的識別符。
statusstring
該資源目前的生命週期狀態。
output_file_idstring|null
供相關 API 使用的檔案識別符。
授權
BearerAuth AuthorizationBearer <token>
API Key 驗證。請在 Dashboard > API > API Keys 建立或管理 API 金鑰。
位置: header
請求標頭
X-TokenLab-Delivery-Policy?string
單次請求傳遞策略。會覆寫 API key 與 Workspace 的預設值。系統會自動優先嘗試 TokenLab Verified,並可能在輸出、請求接受或建立持久性資源前切換至 Official 模式一次。
可選值
- "auto"
- "verified"
- "official"
請求主體
application/json
回應
application/json
application/json
application/json
application/json
application/json