TokenLab

檔案與批次

檢索檔案

檢索單個上傳檔案的元數據。

GET
/v1/files/{file_id}

概述

此端點主要服務於 TokenLab 的 OpenAI 相容 Batch API 檔案物件。

當請求選擇 Anthropic Files 相容模式時,同一路徑也可以回傳繫結工作區的 Anthropic 風格檔案中繼資料。

不帶 Anthropic 標頭時,此路由可能返回批次檔案物件,也可能返回 TokenLab 圖像/參考檔案物件。

注意事項

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

範例

請求

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

請求 / 回應

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

操作提示

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

圖像參考檔案

此端點也可以返回 TokenLab 建立的圖像參考檔案中繼資料。status 欄位是可選的;某些檔案類型可能不會提供該欄位。

回應範例

回應

200 OK
{
  "id": "file_abc123",
  "object": "file",
  "bytes": 32768,
  "created_at": 1706000000,
  "filename": "batch-input.jsonl",
  "purpose": "batch"
}

重要欄位

idstring
供相關 API 使用的檔案識別符。
filenamestring
原始或產生的檔案名稱。
purposestring
所屬工作流程使用的檔案用途,例如 batch、batch_output、user_data 或 vision。

授權

BearerAuth
AuthorizationBearer <token>

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

位置: header

路徑參數

file_id*string

請求標頭

anthropic-beta?string

包含 files-api-2025-04-14 以使用 Anthropic Files API 模式。

回應

application/json

application/json