Create Batch Task
POST http(s)://{{Host}}/v1/batches
Example
Request
curl -X POST "https://${Host}/v1/batches" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer ${apikey}" \
-H "X-BELLA-QUEUE-NAME: test-queue" \
-d '{
"input_file_id": "file-XXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXXXX",
"endpoint": "/v1/chat/completions",
"completion_window": "24h",
"metadata": {
"description": "Customer support chat completions batch"
}
}'
Response
{
"id": "BATCH-X-X-XXXXXXXXXXXX-XXXX-XXXXXX",
"object": "batch",
"endpoint": "/v1/chat/completions",
"input_file_id": "file-XXXXXXXXXXXXXXXXXXXXXXX-XXXXXXXXXX",
"completion_window": "24h",
"created_at": 1762867031064,
"expired_at": 1762953431064,
"request_counts": {
"total": 0,
"completed": 0,
"failed": 0
}
}
Request Headers
| Parameter | Type | Required | Description |
|---|---|---|---|
X-BELLA-QUEUE-NAME | string | Optional | Queue name for batch processing |
Request Body Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
input_file_id | string | Required | Input file ID containing batch requests, upload using File API, refer to File Upload Documentation (Chinese version) |
endpoint | string | Required | API endpoint for processing tasks |
completion_window | string | Required | Completion window, format: number+unit(m/h/d), default "24h" |
metadata | object | Optional | Batch metadata, custom key-value pairs |
Completion Window
Supported time unit formats:
| Unit | Description | Example |
|---|---|---|
m | Minutes | 30m(30 min) |
h | Hours | 24h(24 hrs) |
d | Days | 7d(7 days) |
Default: 24h (24 hours)
Format: number + unit, e.g., 30m, 2h, 1d
Description: Specifies the maximum completion time window for batch tasks. If the provided value format is incorrect, the system will automatically use the default value of 24h.