- Get started
- Introduction
- Authentication
- Making requests
- Streaming
- Audio
- Batch
- Models
- Invites
- Chat
- Users
- Projects
- Project users
- Project service accounts
- Project API keys
- Audit logs
- Usage
- Project rate limits
- Completions
- Uploads
- Embeddings
- Files
- Moderations
- Assistants (v1)
- Threads (v1)
- Messages (v1)
- Runs (v1)
- Images
- Fine-tuning
Create batch
POST
https://api.openai.com/v1/batches
Request
Authorization
Provide your bearer token in the
Authorization
header when making requests to protected resources.Example:
Authorization: Bearer ********************
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
batch
. The file can contain up to 50,000 requests, and can be up to 200 MB in size.endpoint
stringÂ
required
/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
24h
is supported.Example
{
"input_file_id": "file-abc123",
"endpoint": "/v1/chat/completions",
"completion_window": "24h"
}
Request samples
Shell
JavaScript
Java
Swift
Go
PHP
Python
HTTP
C
C#
Objective-C
Ruby
OCaml
Dart
R
Request Request Example
Shell
JavaScript
Java
Swift
curl --location --request POST 'https://api.openai.com/v1/batches' \
--header 'Authorization: Bearer $OPENAI_API_KEY' \
--header 'Content-Type: application/json' \
--data-raw '{
"input_file_id": "file-abc123",
"endpoint": "/v1/chat/completions",
"completion_window": "24h"
}'
Responses
🟢200Success
application/json
Body
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",
}
}
Modified at 2024-12-13 10:20:37