TokenLab

檔案與批次

檢索檔案內容

下載上傳檔案的原始內容。

GET
/v1/files/{file_id}/content

概述

此端點主要服務於 TokenLab 的 OpenAI 相容 Batch API 檔案內容擷取。

當請求選擇 Anthropic Files 相容模式時,同一路徑也可以代理繫結工作區中儲存的原始檔案內容。

不帶 Anthropic 標頭時,此路由下載批次檔案內容;如果提供商支援檔案內容讀取,也會代理已綁定圖像/參考檔案的內容。

注意事項

  • 批次輸入檔案必須使用 purpose=batch。
  • 使用 purpose=batch_output 以聚焦生成的輸出檔案。
  • completion_window 目前為 24h。
  • 輸出順序不保證;始終根據 custom_id 匹配。
  • 批次項目內不支援串流。

範例

請求

cURL
curl -X GET "https://api.tokenlab.sh/v1/files/file_abc123/content" \
  -H "Authorization: Bearer sk-your-api-key" \
  --output batch-output.jsonl

請求 / 回應

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

操作提示

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

內容類型

批次檔案內容會以 JSONL 或純文字返回。當底層檔案提供者支援內容讀取時,TokenLab 建立的圖像參考檔案內容可以作為二進位內容代理返回。

回應範例

回應

200 OK
{"custom_id":"request-1","response":{"status_code":200,"body":{"id":"chatcmpl_abc123"}}}
{"custom_id":"request-2","error":{"code":"invalid_request_error","message":"Invalid model"}}

重要欄位

bodybinary|string
檔案內容。請依 Content-Type 儲存或解析;JSONL 應逐行解析。
custom_idstring
對應批次輸入項目與結果的 ID。

授權

BearerAuth
AuthorizationBearer <token>

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

位置: header

路徑參數

file_id*string

回應

text/plain

application/json