Body Required
-
The ID of an uploaded file that contains requests for the new batch.
See upload file for how to upload a file.
Your input file must be formatted as a JSONL file, and must be uploaded with the purpose
batch
. The file can contain up to 50,000 requests, and can be up to 100 MB in size. -
The endpoint to be used for all requests in the batch. Currently
/v1/chat/completions
,/v1/embeddings
, and/v1/completions
are supported. Note that/v1/embeddings
batches are also restricted to a maximum of 50,000 embedding inputs across all requests in the batch.Values are
/v1/chat/completions
,/v1/embeddings
, or/v1/completions
. -
The time frame within which the batch should be processed. Currently only
24h
is supported.Value is
24h
. -
metadata object | null
Optional custom metadata for the batch.
curl \
-X POST https://api.openai.com/v1/batches \
-H "Authorization: Bearer $ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"input_file_id":"string","endpoint":"/v1/chat/completions","completion_window":"24h","metadata":{"key":"string"}}'
{
"input_file_id": "string",
"endpoint": "/v1/chat/completions",
"completion_window": "24h",
"metadata": {
"key": "string"
}
}
{
"id": "string",
"object": "batch",
"endpoint": "string",
"errors": {
"object": "string",
"data": [
{
"code": "string",
"message": "string",
"param": "string",
"line": 42
}
]
},
"input_file_id": "string",
"completion_window": "string",
"status": "validating",
"output_file_id": "string",
"error_file_id": "string",
"created_at": 42,
"in_progress_at": 42,
"expires_at": 42,
"finalizing_at": 42,
"completed_at": 42,
"failed_at": 42,
"expired_at": 42,
"cancelling_at": 42,
"cancelled_at": 42,
"request_counts": {
"total": 42,
"completed": 42,
"failed": 42
},
"metadata": {}
}