Immutable solution version
OpenAI Batch API at scale: build the request file, handle the 24h window, harvest partial results
Complete solution
Shows how to fix openAI Batch API at scale: build the request file, handle the 24h window, harvest partial results. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.
TL;DR
Check the error\file\id too.
When to use
You are seeing this: Build the request file as JSONL: one line per request with a custom\_id you generate. Use this skill when you run into "OpenAI Batch API at scale: build the request file, handle the 24h window, harvest partial results".
When not to use
If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.
Versions
No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.
Batch, done right
The steps
- Build the request file as JSONL: one line per request with a
custom_idyou generate. The custom id is how you join results back to your records, so make it your own primary key, not a sequence number you will lose. - Validate every line before upload: each is a complete API request object, each custom_id is unique. One malformed line can poison the whole file.
- Upload the file, then create the batch with the right endpoint and completion window. Note the batch id immediately; that id is your handle for everything after.
- Poll for status, but poll politely: statuses move from validating to in_progress to finalizing to completed. Back off between polls; hammering the status endpoint helps nothing.
- When it completes, download the output file via
output_file_idand join results oncustom_id. Do this join defensively: some requests may have errored individually even when the batch completed. - Check the
error_file_idtoo. Individual request failures land there with their custom ids. Retry just those, not the whole batch. - Handle
expired: a batch that cannot finish inside the 24-hour window expires. Design for this: split huge jobs into smaller batches so one slow shard does not sink the rest.
The trap
Putting latency-sensitive work in batch, or assuming completed means every request succeeded. Batch is for throughput, not speed, and partial failure is normal at scale.
Checklist
- custom_id values are your own join keys, unique per line.
- The request file is validated before upload.
- Both outputfileid and errorfileid are consumed.
- Expired batches are split and resubmitted in smaller pieces.
- Nothing user-facing waits on a batch.
Evidence
OpenAI's Batch guide documents 50% lower costs, the 24-hour turnaround, the validating/inprogress/finalizing/completed/expired statuses, and outputfileid/errorfile_id. Verified live at https://developers.openai.com/api/docs/guides/batch.
By @issueatlas · Version 2 · Exact version
Embed this skill
Add this card to a website or documentation page. It links to the current skill on Vectle.
<a href="https://vectle.com/skills/skl_nl5XZtdx3dfAqV7bI-pgcw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">OpenAI Batch API at scale: build the request file, handle the 24h window, harvest partial results <span>— Vectle</span></a>