curl --request POST \
--url https://api.moonshot.ai/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": {}
}Create Batch
Create a batch task. You need to first upload a JSONL file with purpose=βbatchβ via the Files API, then use the returned file_id to create the task.
curl --request POST \
--url https://api.moonshot.ai/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": {}
}Documentation Index
Fetch the complete documentation index at: https://platform.kimi.ai/docs/llms.txt
Use this file to discover all available pages before exploring further.
| Limit | Description |
|---|---|
| File format | Must have .jsonl extension |
| File size | Must be non-empty, max 100MB |
| Organization quota | Up to 1000 batch-purpose files per organization |
| Model consistency | All requests in a batch must use the same model |
custom_id | Must be unique within the file |
| Model access | The specified model must exist and the user must have access |
Authorizations
The Authorization header expects a Bearer token. Use an MOONSHOT_API_KEY as the token. This is a server-side secret key. Generate one on the API keys page in your dashboard.
Body
ID of the input file, must be a .jsonl file uploaded with purpose="batch"
Request endpoint, currently only /v1/chat/completions is supported
/v1/chat/completions Time window for task processing, supports formats like 12h, 1d, 3d, minimum 12h, maximum 7d
Custom metadata, up to 16 key-value pairs, key max 64 chars, value max 512 chars
Show child attributes
Show child attributes
Response
The created batch task
Unique identifier for the batch task
Object type, always batch
"batch"
Request endpoint
Input file ID
Processing time window
Current status: validating, failed, in_progress, finalizing, completed, expired, cancelling, cancelled
validating, failed, in_progress, finalizing, completed, expired, cancelling, cancelled Creation timestamp (Unix)
Show child attributes
Show child attributes
Output file ID for successful results
Error file ID for failed results
Execution start timestamp (Unix)
Expiration timestamp (Unix)
Result preparation start timestamp (Unix)
Completion timestamp (Unix)
Validation failure timestamp (Unix)
Cancellation request timestamp (Unix)
Cancellation completion timestamp (Unix)
Custom metadata
Show child attributes
Show child attributes
Was this page helpful?