创建批处理任务
curl --request POST \
--url https://api.moonshot.cn/v1/batches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input_file_id": "<string>",
"completion_window": "<string>"
}
'{
"id": "<string>",
"object": "batch",
"endpoint": "<string>",
"input_file_id": "<string>",
"completion_window": "<string>",
"created_at": 123,
"request_counts": {
"completed": 123,
"failed": 123,
"total": 123
},
"output_file_id": "<string>",
"error_file_id": "<string>",
"in_progress_at": 123,
"expires_at": 123,
"finalizing_at": 123,
"completed_at": 123,
"failed_at": 123,
"cancelling_at": 123,
"cancelled_at": 123,
"metadata": {}
}创建批处理任务
创建一个批处理任务。需要先通过文件接口上传一个 purpose=“batch” 的 JSONL 文件,然后使用返回的 file_id 创建任务。
POST
/
v1
/
batches
创建批处理任务
curl --request POST \
--url https://api.moonshot.cn/v1/batches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"input_file_id": "<string>",
"completion_window": "<string>"
}
'{
"id": "<string>",
"object": "batch",
"endpoint": "<string>",
"input_file_id": "<string>",
"completion_window": "<string>",
"created_at": 123,
"request_counts": {
"completed": 123,
"failed": 123,
"total": 123
},
"output_file_id": "<string>",
"error_file_id": "<string>",
"in_progress_at": 123,
"expires_at": 123,
"finalizing_at": 123,
"completed_at": 123,
"failed_at": 123,
"cancelling_at": 123,
"cancelled_at": 123,
"metadata": {}
}限制:
| 限制项 | 说明 |
|---|---|
| 文件格式 | 必须为 .jsonl 扩展名 |
| 文件大小 | 不能为空,最大 100MB |
| 组织文件配额 | 每个组织最多 1000 个 batch 类型文件 |
| 模型一致性 | 同一批次内所有请求必须使用相同模型 |
custom_id | 文件内必须唯一 |
| 模型权限 | 指定的模型必须存在且用户有访问权限 |
授权
请求体
application/json
响应
已创建的批处理任务
批处理任务的唯一标识符
对象类型,固定为 batch
示例:
"batch"
请求端点
输入文件 ID
任务处理时间窗口
当前状态:validating(校验中)、failed(校验失败)、in_progress(执行中)、finalizing(准备结果中)、completed(已完成)、expired(已过期)、cancelling(取消中)、cancelled(已取消)
可用选项:
validating, failed, in_progress, finalizing, completed, expired, cancelling, cancelled 创建时间(Unix 时间戳)
Show child attributes
Show child attributes
处理成功的结果文件 ID
处理失败的错误文件 ID
开始执行时间(Unix 时间戳)
过期时间(Unix 时间戳)
开始准备结果的时间(Unix 时间戳)
完成时间(Unix 时间戳)
校验失败时间(Unix 时间戳)
发起取消时间(Unix 时间戳)
取消完成时间(Unix 时间戳)
自定义元数据
Show child attributes
Show child attributes
此页面对您有帮助吗?
⌘I