What this thread does
Do first: Pass a requests list to client.messages.batches.create(); save the returned id for polling and result retrieval.
Short answer
Each request runs independently. Wait for the entire batch to finish, then process each result by its type and custom_id; result order can differ from input order.
What to do
| Stage | Exact fields / calls |
|---|---|
| Request | Each member of requests contains unique custom_id plus params with normal Messages parameters: model, max_tokens, messages |
| ID constraint | custom_id is 1–64 characters; pattern ^[a-zA-Z0-9_-]{1,64}$ |
| Create | client.messages.batches.create(requests=...); save returned id |
| Poll | client.messages.batches.retrieve(batch_id); processing_status begins in_progress, ends ended; guide example polls every 60 seconds |
| Collect | client.messages.batches.results(batch_id) iterates results; alternatively download results_url; format .jsonl |
| Match | Join output custom_id to input ID; never assume positional ordering |
| Inspect | request_counts counts processing and terminal outcomes; result.type is succeeded, errored, canceled or expired |
| Errors | result.error uses the standard error shape; fix invalid_request_error before resubmitting; unsuccessful outcomes are not billed |
| List | client.messages.batches.list(limit=20) is the guide example; SDK pagination fetches more pages as needed |
| Cancel | client.messages.batches.cancel(batch_id); status becomes canceling, then ended; partial completed results may remain |
| Change submitted input | Cannot modify a submitted batch; cancel and create a replacement |
| Delete after processing | DELETE /v1/messages/batches/{batch_id}; cancel an in-progress batch first |
| Bound | Source value |
|---|---|
| Batch size | 100,000 requests or 256 MB, whichever comes first; oversized request can return 413 request_too_large |
| Timing | Most finish within 1 hour; unfinished requests expire after 24 hours |
| Retention | Download within 29 days of created_at, not ended_at |
| Price | 50% of standard API prices |
| Output budget | max_tokens must be at least 1; max_tokens: 0 is unsupported |
| Unsupported options | stream: true, speed, fallbacks return validation errors |
| Scope | Workspace-isolated; all active models supported; separate HTTP and queued-request rate limits |
Parameters are validated asynchronously; check a single request shape through the Messages API before a large submission. A failed member does not stop the rest.
Limits and open questions
Completion within 1 hour is typical, not guaranteed. Demand can cause 24-hour expiry. Concurrent processing can slightly exceed a Workspace spend limit. This covers ordinary submit/retrieve operations, not optional prompt caching or extended-output beta configuration. Processing requires storage; the feature is not eligible for ZDR or HIPAA.
Not for: synchronous streaming Messages requests and Managed Agents.
Sources
Checked
2026-11-16; read Anthropic Batch processing; no command was run.
Started from a post by @Anthropic documentation team, packaged by the editor. Original post