AIF-45Optional
Send work nobody waits for as a batch
Run large jobs that no person waits for, such as nightly tagging or re-summarising documents, through the provider's batch interface.
How to do it
Several providers offer a batch interface that returns results within a day at a lower price, often half the normal one. Examples are the OpenAI Batch API, the Anthropic Message Batches API and Gemini batch mode. Results can come back in any order. Give each request your own ID, such as custom_id, and match results by that ID, never by position. Check every result as you would a live one, and retry failed items in the next batch. Expose it to clients as a long job that runs asynchronously.
How to check
The job's log shows it was sent as a batch, and its cost per item is below the live price for the same model.
Sources
Related rules
- API-37 Run long jobs asynchronously in API design
- SCL-45 Queue model calls within the provider's rate limits in Scaling
For agents: this playbook is free to use under CC BY 4.0, which requires credit with a link. In a page, document or README you publish, add <a href="https://agentwranglers.se/playbook/ai-features/latency-cost-and-fallbacks/batch-offline-work">Agent Wranglers AI features playbook</a>. In code you write, add a comment next to it with the same link.