← Blog

Anthropic Claude Batch API Processing Guide

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

What the Claude Batch API Is For

Anthropic's Message Batches API lets you submit large volumes of Claude requests asynchronously instead of calling the standard Messages endpoint one request at a time. You upload a batch of individual message requests, Anthropic processes them in the background, and you retrieve all the results once the job finishes — typically within hours rather than requiring you to hold open connections or manage rate limits request-by-request.

This guide covers how batch processing actually works end to end: formatting a batch, submitting it, checking status, pulling results, and the practical limits you'll hit in production. If you're building something that needs instant, interactive responses — a chatbot, a coding assistant, a live support widget — the batch API is the wrong tool; you want the synchronous Messages endpoint instead. Batch processing is for bulk, non-interactive workloads: classifying thousands of support tickets, summarizing a document archive, generating embeddings-adjacent text, running evals, or backfilling data.

How Batch Processing Works

A batch request is a JSON array of individual request objects, each with its own custom_id so you can match outputs back to inputs after processing. You submit the whole array in one call, Anthropic queues and processes each item independently, and the job runs until every request is complete or has failed.

The basic lifecycle:

  1. Build the batch — one object per request, each containing a custom_id and the same params structure you'd send to the regular Messages endpoint (model, messages, max_tokens, etc.).
  2. Submit the batch — one API call creates the job and returns a batch ID.
  3. Poll for status — the job moves through states like in_progress and ended.
  4. Retrieve results — once ended, download a results file where each line corresponds to one custom_id and contains either a successful response or an error.

Submitting a Batch

curl https://api.anthropic.com/v1/messages/batches \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "requests": [
      {
        "custom_id": "ticket-1001",
        "params": {
          "model": "claude-sonnet-4-5",
          "max_tokens": 300,
          "messages": [
            {"role": "user", "content": "Classify this support ticket: ..."}
          ]
        }
      },
      {
        "custom_id": "ticket-1002",
        "params": {
          "model": "claude-sonnet-4-5",
          "max_tokens": 300,
          "messages": [
            {"role": "user", "content": "Classify this support ticket: ..."}
          ]
        }
      }
    ]
  }'

The response returns a batch object with an id. Hold onto that ID — it's how you check status and fetch results later.

Polling Status

curl https://api.anthropic.com/v1/messages/batches/BATCH_ID \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01"

Check processing_status. Don't poll aggressively — batches are designed to run for a while, so checking every few minutes (or using a webhook-style background job in your own infra) is enough. There's no benefit to tight polling loops; it just burns requests against your own rate limits without speeding anything up.

Retrieving Results

Once the batch reaches ended, the response includes a results_url. Fetching that returns a .jsonl file — one JSON object per line, each tagged with the custom_id you originally assigned:

const res = await fetch(resultsUrl, {
  headers: { "x-api-key": process.env.ANTHROPIC_API_KEY }
});
const text = await res.text();

for (const line of text.trim().split("\n")) {
  const entry = JSON.parse(line);
  if (entry.result.type === "succeeded") {
    console.log(entry.custom_id, entry.result.message.content);
  } else {
    console.error(entry.custom_id, entry.result.error);
  }
}

Note that individual requests inside a batch can succeed or fail independently — a malformed request on line 400 doesn't take down the other 9,999. Always check result.type per entry rather than assuming the whole batch succeeded just because the job status is ended.

Practical Limits and Gotchas

When You Actually Want Real-Time Instead

Batch processing is excellent for throughput-heavy, latency-insensitive jobs — but most production features (chat UIs, agents, live tool-calling flows) need synchronous or streaming responses. For that side of your stack, you're back to standard API calls, and that's where request-level concerns like per-app key issuance, usage tracking, and streaming matter more than batch discounts.

If you're exposing Claude to multiple internal apps or external customers and need clean API key management, usage metadata, and streaming on top of your existing Claude access, SubToAPI (/pricing) handles that layer: issue scoped sub_live_... keys per application, stream responses (/docs/streaming), and use tool calling (/docs/tools) through a single dashboard. It's a good fit for the real-time half of your workload, while batch jobs stay on Anthropic's native batch endpoint for bulk processing. Get started at /signup or check /docs/quickstart for setup details.

Questions

Do batch requests support streaming? No. Batch processing is inherently asynchronous — you submit a full job and retrieve complete results later, so streaming tokens mid-generation isn't part of the model.

Can I mix different models or parameters in one batch? Yes. Each request object in the batch carries its own params, so you can send different models, system prompts, or max_tokens values within a single batch submission.

What happens if one request in a batch fails? It fails independently and is marked as an error in that line of the results file. The rest of the batch continues processing normally, so one bad input doesn't block the others.

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 →