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 200 MB in size. -
The endpoint to be used for all requests in the batch. Currently
/v1/responses
,/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/responses
,/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
. -
Set of 16 key-value pairs that can be attached to an object. This can be useful for storing additional information about the object in a structured format, and querying for objects via API or the dashboard.
Keys are strings with a maximum length of 64 characters. Values are strings with a maximum length of 512 characters.
curl \
--request POST 'https://api.openai.com/v1/batches' \
--header "Authorization: Bearer $ACCESS_TOKEN" \
--header "Content-Type: application/json" \
--data '{"input_file_id":"string","endpoint":"/v1/responses","completion_window":"24h","metadata":{"additionalProperty1":"string","additionalProperty2":"string"}}'
{
"input_file_id": "string",
"endpoint": "/v1/responses",
"completion_window": "24h",
"metadata": {
"additionalProperty1": "string",
"additionalProperty2": "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": {
"additionalProperty1": "string",
"additionalProperty2": "string"
}
}