Claude API Batch Processing: Bulk Requests Guide
Processing thousands of prompts through the Claude API — summarizing documents, classifying support tickets, generating product descriptions — requires a different approach than calling the API once in a chat UI. You need to decide whether to use Anthropic's native batch endpoint, build your own concurrency layer, or some mix of both, and you need a plan for rate limits, retries, and cost tracking before you fire off a 50,000-row job.
The short answer: for jobs where you don't need results immediately, use a native batch API and accept slower turnaround for a lower price. For jobs that need near-real-time results but still touch hundreds or thousands of items, build a controlled concurrency pool with retry logic and backoff. Both approaches are covered below, along with the operational details that actually determine whether a bulk job finishes cleanly or falls over halfway through.
What "Batch Processing" Means for the Claude API
Two distinct patterns get called "batch processing":
- Asynchronous batch jobs — you submit a large set of requests together, Anthropic processes them over a window (often hours), and you retrieve results later. This trades latency for lower per-request cost.
- Concurrent synchronous requests — you still call the standard messages endpoint, but you fire many requests in parallel from your own infrastructure, respecting rate limits, to get results faster than one-at-a-time calling would allow.
Which one you need depends on whether your downstream process can wait. A nightly content-tagging job fits async batching. A user-facing bulk upload that needs a progress bar fits concurrent synchronous calls.
Native Batch Processing
Anthropic offers a dedicated batch endpoint for Claude where you submit an array of requests as a single job, each with its own custom_id, model, and messages payload. The job runs asynchronously and you poll a status endpoint until it completes, then download a results file matching each response back to its custom_id. This is the right tool when:
- You have more than a few hundred items to process.
- Results don't need to come back in seconds.
- You want a meaningfully lower cost per request than real-time calls.
The tradeoff is turnaround time and the fact that you can't stream individual outputs — you get everything back once the job finishes. If your pipeline is a cron job or an ETL step, this is usually the better fit than hand-rolled concurrency.
Concurrent Requests With a Worker Pool
When you need faster turnaround, the standard pattern is a bounded worker pool: a fixed number of requests in flight at any time, with a queue feeding new items as slots free up.
const CONCURRENCY = 5;
const queue = [...items];
const results = [];
async function worker() {
while (queue.length) {
const item = queue.shift();
try {
const res = await fetch("https://api.anthropic.com/v1/messages", {
method: "POST",
headers: {
"content-type": "application/json",
"x-api-key": process.env.ANTHROPIC_API_KEY,
"anthropic-version": "2023-06-01"
},
body: JSON.stringify({
model: "claude-sonnet-4-5",
max_tokens: 500,
messages: [{ role: "user", content: item.prompt }]
})
});
results.push(await res.json());
} catch (err) {
results.push({ error: err.message, item });
}
}
}
await Promise.all(Array.from({ length: CONCURRENCY }, worker));
Five to ten workers is a reasonable starting point. Push it higher only after you've confirmed your rate limit headroom — going too wide too fast is the most common reason bulk jobs start throwing 429s.
Handling Rate Limits and Retries
Bulk jobs live or die on how they handle throttling. A few rules that hold up in practice:
- Respect
retry-afterheaders. Don't guess backoff timing — use what the API tells you. - Use exponential backoff with jitter for any error that isn't a hard failure (429s, 503s, transient network errors).
- Separate retryable from non-retryable errors. A malformed prompt will fail every time; retrying it just burns quota. A rate limit or timeout is worth retrying.
- Make requests idempotent where possible — include a stable
custom_idor correlation ID in your own logging so a retried request doesn't produce duplicate downstream writes.
async function callWithRetry(payload, attempt = 0) {
const res = await fetch(url, { method: "POST", headers, body: JSON.stringify(payload) });
if (res.status === 429 && attempt < 5) {
const wait = Number(res.headers.get("retry-after") || 2 ** attempt);
await new Promise(r => setTimeout(r, wait * 1000));
return callWithRetry(payload, attempt + 1);
}
return res.json();
}
Chunking Large Datasets
If you're processing a CSV with 20,000 rows, don't load it into memory as one array and loop. Chunk it:
- Read and process in batches of a few hundred rows.
- Checkpoint progress to disk or a database after each chunk completes, so a crash halfway through doesn't mean starting over.
- Log failed items separately so you can re-run just the failures instead of the whole dataset.
This matters more than it sounds — bulk jobs that don't checkpoint are the ones that get re-run three times because of one bad row near the end.
Cost and Latency Tradeoffs
Async batch jobs are cheaper per token but can take hours. Concurrent synchronous calls are faster but cost more and compete with your production rate limits if you're running them on the same API key as live traffic. A common fix is to isolate bulk workloads onto a separate key so a runaway job doesn't eat into the quota your live application needs.
This is where a layer like SubToAPI helps if you're already running Claude through it: application keys (sub_live_...) let you issue a dedicated key for a bulk job separate from your production app key, and usage metadata on each response lets you see exactly how many tokens the job consumed without digging through raw logs. Streaming is also available for long individual outputs inside a bulk run — see the streaming docs — and if your bulk job involves structured extraction rather than free text, tool use gives you consistent JSON back instead of parsing prose. Setup takes the same five minutes as the quickstart, and plans scale by seat starting at €9/month with a free trial at signup.
A Practical Pattern for Bulk Jobs
For most teams, the pattern that works is:
- Use the async batch endpoint for anything over a few hundred items with no real-time requirement.
- Use a bounded concurrency pool (5–10 workers) for smaller or latency-sensitive jobs.
- Checkpoint progress and separate retryable from permanent failures.
- Run bulk workloads on a dedicated key so they don't compete with production traffic.
- Log token usage per job so costs are visible before they surprise you at billing time.
Questions
Does Claude have a native batch API, or do I have to build concurrency myself? Anthropic provides an asynchronous batch endpoint for large jobs that don't need immediate results, at a lower per-request cost than real-time calls. For latency-sensitive bulk work, you build your own bounded concurrency on top of the standard messages endpoint.
How many requests can I run in parallel without hitting rate limits? It depends on your account's rate limit tier, not a fixed number. Start with 5–10 concurrent workers, watch for 429 responses and retry-after headers, and scale up only once you've confirmed headroom.
Should bulk jobs use the same API key as my production app? No — isolate bulk workloads on a separate key where possible. It prevents a large batch job from consuming the rate limit quota your live application needs, and makes it easier to track cost per job.