Create batch
POSThttps:/api.openai.com/v1/batches
Creates and executes a batch from an uploaded file of requests
Request body
input_file_id
string
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.endpoint
string
Required
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./v1/responses
string
/v1/chat/completions
string
/v1/embeddings
string
/v1/completions
string
completion_window
string
Required
The time frame within which the batch should be processed. Currently only
24h
is supported.24h
string
metadata
object or null
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.
Response
The created Batch object.
Example request
1 curl https://api.openai.com/v1/batches \2 -H "Authorization: Bearer $OPENAI_API_KEY" \3 -H "Content-Type: application/json" \4 -d '{5 "input_file_id": "file-abc123",6 "endpoint": "/v1/chat/completions",7 "completion_window": "24h"8 }'
Example response
1 {2 "id": "batch_abc123",3 "object": "batch",4 "endpoint": "/v1/chat/completions",5 "errors": null,6 "input_file_id": "file-abc123",7 "completion_window": "24h",8 "status": "validating",9 "output_file_id": null,10 "error_file_id": null,11 "created_at": 1711471533,12 "in_progress_at": null,13 "expires_at": null,14 "finalizing_at": null,15 "completed_at": null,16 "failed_at": null,17 "expired_at": null,18 "cancelling_at": null,19 "cancelled_at": null,20 "request_counts": {21 "total": 0,22 "completed": 0,23 "failed": 024 },25 "metadata": {26 "customer_id": "user_123456789",27 "batch_description": "Nightly eval job",28 }29 }
Built with