首批通过分布式安全可靠测评,为关键业务系统打造
Create batch - 创建 Batch 任务
更新时间:2026-07-03 13:12:54
功能说明
OpenAI 兼容 Batches API,用已上传的 JSONL 文件创建批量任务。当前仅支持阿里云 qwen 系列模型。
调用说明
接口约束
- 调用者需要拥有 API Key,详情请参见 管理 AI API Key。
请求路径
POST {BASE_URL}/api/v1/batches
请求头
| 名称 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|
| Authorization | 是 | Bearer {token} | 鉴权信息 |
| Content-Type | 否 | application/json | 请求体格式 |
请求参数
Path 参数
此接口无 Path 参数。
Query 参数
此接口无 Query 参数。
Body 参数
| 名称 | 类型 | 是否必填 | 示例值 | 描述 |
|---|---|---|---|---|
| input_file_id | string | 是 | file-abc123 | 已上传的 JSONL 文件 ID |
| endpoint | string | 是 | /v1/chat/completions | 批量任务的目标 API 端点 |
| completion_window | string | 是 | 24h | 批量任务的完成时间窗口 |
| metadata | object | 否 | {"description": "nightly eval job"} | 可选的元数据对象 |
返回结果
返回参数
| 名称 | 类型 | 描述 |
|---|---|---|
| success | boolean | 请求是否成功 |
| code | string | 返回码 |
| message | string | 返回信息 |
| data | object | 业务返回数据 |
data 字段说明
| 名称 | 类型 | 描述 |
|---|---|---|
| id | string | 批量任务的唯一 ID |
| object | string | 对象类型,例如 "batch" |
| endpoint | string | 批量任务的目标 API 端点 |
| input_file_id | string | 已上传的 JSONL 文件 ID |
| completion_window | string | 批量任务的完成时间窗口 |
| status | string | 批量任务状态 |
| created_at | integer | 创建时间戳 |
请求示例
curl --request POST '{BASE_URL}/api/v1/batches' \
--header 'Authorization: Bearer {token}' \
--header 'Content-Type: application/json' \
--data '{
"input_file_id": "file-abc123",
"endpoint": "/v1/chat/completions",
"completion_window": "24h",
"metadata": {
"description": "nightly eval job"
}
}'
返回示例
{
"success": true,
"code": "200",
"message": "successful",
"data": {
"id": "batch_abc123",
"object": "batch",
"endpoint": "/v1/chat/completions",
"input_file_id": "file-abc123",
"completion_window": "24h",
"status": "validating",
"created_at": 1711234567
}
}