← Blog

Claude API Bulk Request Batching Strategy Guide

2026-11-24 · 5 min read · SubToAPI Team

When you need to process thousands of prompts against Claude — scoring support tickets, classifying documents, generating product descriptions — sending them one at a time in a loop will hit rate limits, waste money on retries, and take far longer than it should. A batching strategy means deciding how many requests run concurrently, how work is grouped, how failures are retried, and whether you use synchronous calls or an async batch endpoint.

The right answer depends on your latency requirements. If you need results within seconds (a live user-facing feature), you batch with controlled concurrency over the standard Messages endpoint. If you can wait minutes to hours (offline processing, nightly jobs, data pipelines), you should use a dedicated batch/async API designed for bulk throughput at a lower cost. Most teams doing bulk Claude work end up mixing both: concurrency-limited synchronous calls for anything time-sensitive, and true batch processing for everything else.

Why naive loops fail at scale

A simple for loop that awaits each request sequentially is correct but slow — if each call takes 2 seconds, 10,000 calls take over 5.5 hours. The obvious fix, firing all requests at once with Promise.all, trades one problem for another: you'll blow through rate limits (requests-per-minute and tokens-per-minute), get a wave of 429 errors, and potentially get temporarily throttled harder as a result.

The fix is bounded concurrency: run N requests in parallel, where N is tuned to your account's actual rate limit, not an arbitrary number.

Step 1: know your real limits before you write code

Rate limits are usually expressed as requests-per-minute and tokens-per-minute, and the token limit is often the binding constraint for bulk jobs with long prompts. Before building a batching layer, log the headers returned on a few real requests (remaining quota, reset time) and use those numbers to size your concurrency pool — guessing leads to either wasted capacity or constant 429s.

Step 2: use a concurrency pool, not Promise.all

A simple worker-pool pattern keeps a fixed number of requests in flight and pulls the next item as soon as one finishes:

async function runBatch(items, worker, concurrency = 8) {
  const results = new Array(items.length);
  let cursor = 0;

  async function runNext() {
    const i = cursor++;
    if (i >= items.length) return;
    results[i] = await worker(items[i], i);
    return runNext();
  }

  const lanes = Array.from({ length: concurrency }, () => runNext());
  await Promise.all(lanes);
  return results;
}

Start with a low concurrency (4–8), watch your error rate and latency, and increase gradually. Treat concurrency as a dial you tune against observed throttling, not a fixed constant.

Step 3: retry with backoff, not a fixed delay

Bulk jobs will hit transient errors — rate limits, timeouts, occasional 5xxs. A flat retry delay either wastes time or hammers the API right when it's already overloaded. Exponential backoff with jitter is the standard fix:

async function withRetry(fn, maxAttempts = 5) {
  for (let attempt = 1; attempt <= maxAttempts; attempt++) {
    try {
      return await fn();
    } catch (err) {
      if (attempt === maxAttempts || !isRetryable(err)) throw err;
      const delay = Math.min(1000 * 2 ** attempt, 30000);
      const jitter = Math.random() * 500;
      await new Promise(r => setTimeout(r, delay + jitter));
    }
  }
}

function isRetryable(err) {
  return err.status === 429 || err.status >= 500;
}

Only retry errors that are actually transient. A malformed prompt or an auth error will fail every time — retrying it just burns budget and adds latency to your job.

Step 4: group by cost, not just by count

If your bulk job mixes short classification prompts with long document summaries, a flat "8 requests at a time" rule wastes capacity on the small jobs and throttles the large ones. Estimate token count per item up front (even roughly, by character count) and group items into batches with a similar total-token budget, so your concurrency pool processes comparable workloads per lane. This keeps throughput predictable and makes cost estimation accurate before you run the job.

Step 5: checkpoint progress

Any bulk job over a few hundred items should write results incrementally — to a database row, a JSON lines file, or a queue — rather than holding everything in memory until the end. If the process crashes at item 8,000 of 10,000, you want to resume from 8,000, not restart from zero. Store the input ID alongside the result so re-runs can skip completed items idempotently.

Step 6: separate "must be fast" from "can wait"

Not every bulk workload needs to finish in seconds. If you're re-scoring your entire historical ticket backlog, there's no reason to compete with live traffic for rate-limit headroom. Route latency-sensitive calls through your normal concurrency-pooled path, and route large offline jobs through a lower-priority queue that runs during off-peak hours or uses a dedicated batch-oriented endpoint with relaxed timing in exchange for lower per-token cost.

Where SubToAPI fits

If you're already running Claude access through SubToAPI, the same batching strategy applies directly — issue a dedicated sub_live_... key for your bulk job (separate from your interactive app's key) so you can track its usage independently and set a sane concurrency limit without affecting user-facing traffic. The Messages docs cover request formatting, and the streaming docs are useful if any step in your pipeline needs partial output instead of waiting for full completions. Check pricing to confirm which plan's seat and usage limits fit your expected bulk volume, and start from the quickstart if you haven't wired up a key yet.

A reasonable default to start with

For most teams, a solid starting point is: concurrency of 6–8, exponential backoff with 5 max attempts, token-aware grouping if prompt sizes vary by more than 2x, and incremental checkpointing to disk or a database. Measure actual throughput and error rate after the first 500 items, then adjust concurrency up or down before running the full set.

Questions

How many concurrent requests should I send to Claude's API for a bulk job? Start at 4–8 concurrent requests and tune based on observed 429 rates and your account's rate limits — there's no universal number, it depends on your token-per-minute allowance and average prompt size.

Should I use a batch API or just loop with concurrency control? Use concurrency-controlled synchronous calls when you need results within seconds; use an async/batch-oriented approach when the job can run over minutes or hours, since it's typically cheaper and removes rate-limit pressure from your live traffic.

What's the biggest mistake in bulk Claude API processing? Firing all requests at once with no concurrency limit and no backoff — it triggers cascading 429 errors, wastes retry budget, and often finishes slower than a properly throttled pool would.

Turn your Claude access into an HTTPS API

SubToAPI gives you application API keys, streaming, tool use and usage insights on top of your existing Claude access — set up in minutes.

Start free  Read the quickstart →