Skip to content
Software capabilities
OpenAI API

Submit a batch of Responses API requests

Upload a JSONL input file for batch processing, then create a batch targeting the Responses API. Use the REST API or OpenAI SDK to submit it.

Documentation reviewed · 2 methods with sources

Ways to do it

  1. API: POST /v1/batches
  2. SDK: openai.batches.create()
API

POST /v1/batches

Create a batch from an uploaded input file and select /v1/responses as its endpoint.

Read source: OpenAI create batch API reference
Requirements
An OpenAI API key, an uploaded JSONL file with purpose=batch, and a supported endpoint and completion window.
Limitations
The input file can contain at most 50,000 requests and be 200 MB. A batch that expires cancels unfinished requests, while completed results remain available.

Example shell

curl https://api.openai.com/v1/batches \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"input_file_id":"file-abc123","endpoint":"/v1/responses","completion_window":"24h"}'
SDK

openai.batches.create()

Submit the uploaded file through the OpenAI SDK and retrieve the resulting batch object.

Read source: OpenAI Batch API guide
Requirements
The OpenAI SDK initialized with an API key and the ID of a JSONL file uploaded for batch use.
Limitations
Batch jobs are asynchronous and can expire before every request completes. Check the batch status and collect the output file.

Example text

const batch = await openai.batches.create({ input_file_id: fileId, endpoint: "/v1/responses", completion_window: "24h" });