Back to catalog / Agent workflows
Submit and reconcile offline message batches
Submit many independent prompts asynchronously, then reconcile successes and failures by custom_id.
Goal
Goal: Submit many independent prompts asynchronously, then reconcile successes and failures by `custom_id`.
Steps
- Assign each request a stable
custom_idand build a{"custom_id":..., "params":{...}}request. [batch] - Submit with
client.beta.messages.batches.create(requests=...), persist the batch ID, and pollretrieve(batch_id)untilprocessing_status == "ended". [batch] - Read result items into a result store using idempotent upserts by
custom_id; separate success, error, and missing items. [batch]
How to verify
The request count reconciles to success, failure, and missing items; retry only failed items and retain original batch mapping.
Troubleshooting
If a batch stalls, poll with bounded backoff and retain status; creation success does not mean every item completed.
Permissions
Prerequisites
- Python 3.11+, Anthropic API key, batch beta SDK, and a replayable list of independent prompts.
Permissions
- De-identify inputs; keep personal data out of `custom_id`; restrict access and retention for prompts/results.
Limitations
Batches are asynchronous and one-shot; handle expiration, per-item failure, and retention; do not use for interactive latency.
Pinned upstream source
- Repository
- anthropics/anthropic-cookbook
- File path
- misc/batch_processing.ipynb
- Pinned commit
9c1e493ddd2b82df399d2a61b9c806c539e18be6- Source checked
- 2026-10-14 · Reviewed against the pinned upstream source
Repository metrics
These values describe the upstream repository, not popularity or likes for an individual skill or playbook.
- Stars
- Not collected
- Forks
- Not collected
- Observed at
- Not collected
No metrics snapshot is available yet.
License: MIT
Main topic
Turn ecommerce campaign materials into a reviewable weekly brief