API手册
创建batch任务
上传文件
AuthorizationBearer <token>required
添加 Header 'Authorization: Bearer {账户 API Key}' 进行鉴权
In: header
input_file_idstringrequired
包含新批量任务请求的上传文件 ID。
Example
"file-jkvytbjtow"endpointstringrequired
批量任务中所有请求使用的端点。目前支持 /v1/chat/completions。
Example
"/v1/chat/completions"completion_windowstringrequired
批量任务应在多长时间内完成处理。最大值为 24 小时,最小值为 336 小时。
Example
"24h"metadataobject
可附加到对象的 16 个键值对集合。可用于以结构化格式存储有关对象的附加信息,并通过 API 或仪表板查询对象。<\br>键为字符串,最大长度为 64 个字符。值为字符串,最大长度为 512 个字符。
replaceobject
用于替换批次中所有请求的参数。
Response Body
成功响应
TypeScript Definitions
Use the response body type in TypeScript.
idstring
Example
"batch_rdyqgrcgjg"objectstring
Example
"batch"endpointstring
Example
"/v1/chat/completions"errorsarray<string>
input_file_idstring
Example
"file-jkvytbjtow"completion_windowstring
Example
"24h"statusstring
Example
"in_queue"output_file_idstring
error_file_idstring
created_atinteger
Example
1741685413in_progress_atinteger
expires_atinteger
Example
1741771813finalizing_atinteger
completed_atinteger
failed_atinteger
expired_atinteger
cancelling_atinteger
cancelled_atinteger
request_countsobject
Empty Object
metadataobject
curl --request POST \
--url https://api.siliconflow.cn/v1/batches \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{
"input_file_id": "file-jkvytbjtow",
"endpoint": "/v1/chat/completions",
"completion_window": "24h",
"metadata": {
"description": "nightly eval job"
},
"replace": {
"model": "deepseek-ai/DeepSeek-V3"
}
}'
import requests
url = "https://api.siliconflow.cn/v1/batches"
payload = {
"input_file_id": "file-jkvytbjtow",
"endpoint": "/v1/chat/completions",
"completion_window": "24h",
"metadata": {"description": "nightly eval job"},
"replace": {"model": "deepseek-ai/DeepSeek-V3"}
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.request("POST", url, json=payload, headers=headers)
print(response.text)
const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: '{"input_file_id":"file-jkvytbjtow","endpoint":"/v1/chat/completions","completion_window":"24h","metadata":{"description":"nightly eval job"},"replace":{"model":"deepseek-ai/DeepSeek-V3"}}'
};
fetch('https://api.siliconflow.cn/v1/batches', options)
.then(response => response.json())
.then(response => console.log(response))
.catch(err => console.error(err));
{
"id": "batch_rdyqgrcgjg",
"object": "batch",
"endpoint": "/v1/chat/completions",
"errors": null,
"input_file_id": "file-jkvytbjtow",
"completion_window": "24h",
"status": "in_queue",
"output_file_id": null,
"error_file_id": null,
"created_at": 1741685413,
"in_progress_at": null,
"expires_at": 1741771813,
"finalizing_at": null,
"completed_at": null,
"failed_at": null,
"expired_at": null,
"cancelling_at": null,
"cancelled_at": null,
"request_counts": null,
"metadata": {
"description": "nightly eval job"
}
}{
"code": 20012,
"message": "string",
"data": "string"
}"Invalid token""Forbidden""404 page not found"{
"code": 50505,
"message": "Model service overloaded. Please try again later.",
"data": "string"
}"string"