TokenLab

檔案與批次

列出檔案

列出已上傳的 batch 與圖片參照檔案。

GET
/v1/files

列出 batch 與圖片參照檔案。可使用 purpose=batch、purpose=batch_output、purpose=user_data 或 purpose=vision 進行篩選。

搭配 Anthropic Files 標頭時,相同的 API 會列出目前 Workspace 中 Anthropic 格式的檔案。

範例

請求

cURL
curl -X GET "https://api.tokenlab.sh/v1/files?purpose=batch&limit=20" \
  -H "Authorization: Bearer sk-your-api-key"

篩選條件

  • 對於 batch 與圖片參照檔案,limit 為 1–10000(預設為 10000),並使用 after 進行分頁。在 Anthropic Files 模式下,limit 為 1–1000(預設為 20);請使用 after_id 或 before_id 其中之一,不可兩者同時使用。
  • purpose 可為 batch、batch_output、user_data 或 vision。
  • user_data 與 vision 會在可用時傳回 TokenLab 建立的圖片參照檔案。

回應範例

回應

200 OK
{
  "object": "list",
  "data": [{ "id": "file_abc123", "object": "file", "purpose": "batch" }],
  "first_id": "file_abc123",
  "last_id": "file_abc123",
  "has_more": false
}

重要欄位

objectstring
固定為 list。
dataarray
檔案清單。
has_moreboolean
當 has_more 為 true 時,表示還有更多結果可供取得。

授權

BearerAuth
AuthorizationBearer <token>

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

位置: header

查詢參數

limit?integer

要回傳的檔案數量。批次與圖片檔案為 1 至 10,000(預設 10,000);Anthropic Files 模式下為 1 至 1,000(預設 20)。

範圍1 <= value <= 10000
after?string
after_id?string

Anthropic Files 游標。返回此公開檔案 ID 之後的檔案。需要 Anthropic Files beta 標頭,且不能與 before_id 結合使用。

before_id?string

Anthropic Files 游標。返回此公開檔案 ID 之前的檔案。需要 Anthropic Files beta 標頭,且不能與 after_id 結合使用。

scope_id?string

保留的 Anthropic Files 範圍游標。TokenLab 目前會返回明確的不支援錯誤,而不是靜默忽略此值。

purpose?string

選填的檔案用途篩選器。batch 和 batch_output 涵蓋 Batch API 檔案;user_data 和 vision 涵蓋 TokenLab 圖片/參考檔案綁定。Anthropic Files API 模式由 Anthropic 標頭選定,而非此查詢參數。

可選值

  • "batch"
  • "batch_output"
  • "user_data"
  • "vision"

請求標頭

anthropic-beta?string

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

回應

application/json

application/json