[ ABORT TO HUD ]
SEQ. 1
SEQ. 2
SEQ. 3
The Batch API
50% Cost Savings for Async Work
The Batch API lets you submit large batches of requests asynchronously. In exchange for flexible completion times (up to 24 hours), you get a 50% discount on input/output tokens.
When to Use Batch API
| ✅ Good Fit | ❌ Bad Fit |
|---|---|
| Bulk classification (10K+ items) | Real-time chat responses |
| Dataset labeling/annotation | User-facing interactions |
| Content moderation queues | Time-sensitive queries |
| Embedding generation at scale | Interactive agents |
// 1. Create a JSONL file of requests
// 2. Upload it
const file = await openai.files.create({
file: fs.createReadStream("batch_requests.jsonl"),
purpose: "batch"
});
// 3. Submit the batch
const batch = await openai.batches.create({
input_file_id: file.id,
endpoint: "/v1/responses",
completion_window: "24h"
});
// 4. Poll for completion
const status = await openai.batches.retrieve(batch.id);
// status.status: "completed" → download results
💡 Pro Tip: Batch API works with all endpoints - Responses, Chat Completions, Embeddings, and even Image Generation. Use it for any high-volume, non-urgent workload.
⌨ HANDS-ON LABSubmit Your First Batch Job
⭐ +200 XP10,000 classification requests, none urgent. Upload a .jsonl input file, then create a batch - 50% cheaper than synchronous calls with a 24h completion window.
1Upload your batchinput.jsonl via the Files API with curl, setting purpose to 'batch'.
2Create the batch: POST to /v1/batches referencing the file ID, endpoint and the 24h completion window.
OBJECTIVE 1 / 2 — type "hint" if stuck
SYNAPSE VERIFICATION
QUERY 1 // 3
How much discount does the Batch API provide?
10%
25%
50% on input/output tokens
75%