文件与批处理
列出文件
列出当前工作区已上传的文件。
列出批处理文件和图片参考文件。可用 purpose=batch、purpose=batch_output、purpose=user_data 或 purpose=vision 筛选。
携带 Anthropic Files 请求头时,返回当前工作区的 Anthropic 格式文件。
请求
curl -X GET "https://api.tokenlab.sh/v1/files?purpose=batch&limit=20" \
-H "Authorization: Bearer sk-your-api-key"筛选条件
- 批处理和图片参考文件的
limit为 1–10000,默认 10000,可用after分页。Anthropic Files 模式的limit为 1–1000,默认 20;分页使用after_id或before_id,不能同时使用。 purpose可以是batch、batch_output、user_data或vision。- 当存在 TokenLab 创建的图像参考文件时,
user_data和vision会返回这些文件。
响应
{
"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 Key。
位置: header
查询参数
limit?integer
范围
1 <= value <= 1000默认值
20after?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