Create batch
POST
https://api.openai.com/v1/batchesCreates and executes a batch from an uploaded file of requests
Request
Header Params
Authorization
string
required
Example:
Bearer $OPENAI_API_KEY
Content-Type
string
required
Example:
application/json
Body Params application/json
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/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.
completion_window
string
required
The time frame within which the batch should be processed. Currently only 24h
is supported.
Example
{
"input_file_id": "file-abc123",
"endpoint": "/v1/chat/completions",
"completion_window": "24h"
}
Request samples
Responses
Success(200)
HTTP Code: 200
Content Type : JSONapplication/json
Data Schema
id
string
required
object
string
required
endpoint
string
required
errors
null
required
input_file_id
string
required
completion_window
string
required
status
string
required
output_file_id
null
required
error_file_id
null
required
created_at
integer
required
in_progress_at
null
required
expires_at
null
required
finalizing_at
null
required
completed_at
null
required
failed_at
null
required
expired_at
null
required
cancelling_at
null
required
cancelled_at
null
required
request_counts
object
required
total
integer
required
completed
integer
required
failed
integer
required
metadata
object
required
customer_id
string
required
batch_description
string
required
Example
{
"id": "batch_abc123",
"object": "batch",
"endpoint": "/v1/chat/completions",
"errors": null,
"input_file_id": "file-abc123",
"completion_window": "24h",
"status": "validating",
"output_file_id": null,
"error_file_id": null,
"created_at": 1711471533,
"in_progress_at": null,
"expires_at": null,
"finalizing_at": null,
"completed_at": null,
"failed_at": null,
"expired_at": null,
"cancelling_at": null,
"cancelled_at": null,
"request_counts": {
"total": 0,
"completed": 0,
"failed": 0
},
"metadata": {
"customer_id": "user_123456789",
"batch_description": "Nightly eval job",
}
}
Last modified: 15 days ago