创建 batch

POST/v1/batches

基于已上传的 JSONL 输入文件(purpose=batch)创建异步 batch 作业。平台会校验文件、要求全文件单一 body.model、解析执行路径(auto / provider / platform)并入队。

MVP 仅支持 endpoint=/v1/chat/completionscompletion_window=24h

JSONL 格式、双执行路径与约束见 批量任务

Authentication

Authorization Bearer

Request Body

input_file_idstringrequired

POST /v1/files(purpose=batch)返回的文件 ID。

endpointstring

必须为 /v1/chat/completions(可省略,默认即此值)。

completion_windowstring

必须为 24h(可省略,默认即此值)。

executionstring

auto(默认)| provider | platform。auto 在可用时优先上游 Batch Infer,否则走平台 fan-out。

callback_urlstring

可选 HTTPS。batch 进入 completed/failed/cancelled/expired 时 POST。覆盖控制台账户默认 Webhook。内网/回环地址会被拒绝。详见 Webhook 文档。

metadataobject

可选键值元数据,保存在 batch 对象上。

Response

idstring

Batch ID(batch_ 前缀)。

objectstring

batch

endpointstring

/v1/chat/completions

statusstring

validating,随后 in_progress 等

execution_preferencestring

请求路径:auto | provider | platform。

executionstring

实际解析路径:provider | platform。

fallback_from_providerboolean

auto 从 provider 回落到 platform 时为 true。

input_file_idstring

输入文件 ID。

client_modelstring

JSONL 中的公网模型名。

output_file_idstring

完成后设置。

error_file_idstring

存在部分失败或错误文件时设置。

completion_windowstring

24h

request_countsobject

可用时含 total、completed、failed。

request_counts.totalinteger

Total number of requests in the batch.

request_counts.completedinteger

Number of completed requests.

request_counts.failedinteger

Number of failed requests.

created_atinteger

Unix 时间戳。

expires_atinteger

估计截止时间(创建 + 24h)。platform 路径仅作展示,到期不会强行停任务。

metadataobject

请求 metadata 回显。

常见错误

batch_multiple_models输入文件中出现多个不同的 body.model
batch_invalid_jsonl行格式或字段非法。
batch_model_not_supported该账号下模型无法作为 batch 运行(无可用路由)。
batch_routing_unavailable模型无活跃 SKU。
missing_execution_api_key会话无法密封推理 API Key Bearer(请使用 API Key 的 Authorization)。

请求

1curl -X POST https://api.token360.ai/v1/batches \
2  -H "Authorization: Bearer sk-your-api-key" \
3  -H "Content-Type: application/json" \
4  -d '{
5    "input_file_id": "file_abc123",
6    "endpoint": "/v1/chat/completions",
7    "completion_window": "24h",
8    "execution": "auto",
9    "callback_url": "https://your-app.example.com/webhooks/batch",
10    "metadata": {"job": "nightly"}
11  }'

响应

JSON
1{
2  "id": "batch_01abc",
3  "object": "batch",
4  "endpoint": "/v1/chat/completions",
5  "status": "validating",
6  "execution_preference": "auto",
7  "execution": "platform",
8  "fallback_from_provider": false,
9  "input_file_id": "file_abc123",
10  "client_model": "gpt-4o-mini",
11  "output_file_id": null,
12  "error_file_id": null,
13  "completion_window": "24h",
14  "request_counts": {"total": 2, "completed": 0, "failed": 0},
15  "created_at": 1710000000,
16  "expires_at": 1710086400,
17  "metadata": {"job": "nightly"}
18}
此页面对您有帮助吗?