Skip to content

Message batches (Anthropic)

Anthropic's Message Batches API doesn't go through the gateway. A call to /v1/messages/batches is refused with a 400 and nothing is sent to any provider. Below: why, and two ways to get the same work done through the gateway.

What it is

The Message Batches API (client.messages.batches.create(...), POST /v1/messages/batches, and the list, retrieve, results and cancel calls under it) runs many Messages requests asynchronously at a lower price.

Why it doesn't work

A batch names its models inside each request, not at the top of the call. The gateway decides where a call goes, and whether the key may make it, from the model name at the top, so it can't place a batch. Rather than guess, it answers 400 with the message "Missing required field: 'model'" (x-vidai-error-code: bad_request).

What to do instead

Need Use
The same work, call by call Send each request to /v1/messages, a few at a time. Every call is governed, recorded and charged on its own, and can use any provider's model
A lower price for bulk work OpenAI's Batch API on an OpenAI model: Batches. It goes through the gateway to OpenAI and Azure OpenAI
import anthropic
from concurrent.futures import ThreadPoolExecutor

client = anthropic.Anthropic()
prompts = ["Summarise A", "Summarise B", "Summarise C"]

def ask(prompt):
    m = client.messages.create(model="claude-sonnet-4.5", max_tokens=300,
                               messages=[{"role": "user", "content": prompt}])
    return m.content[0].text

with ThreadPoolExecutor(max_workers=4) as pool:
    answers = list(pool.map(ask, prompts))
import Anthropic from "@anthropic-ai/sdk";

const client = new Anthropic();
const prompts = ["Summarise A", "Summarise B", "Summarise C"];
const answers = await Promise.all(prompts.map(async (p) => {
  const m = await client.messages.create({ model: "claude-sonnet-4.5", max_tokens: 300,
    messages: [{ role: "user", content: p }] });
  return m.content[0].type === "text" ? m.content[0].text : "";
}));

Keep the number of calls in flight within your key's limits: a 429 with concurrency_limit_exceeded or rate_limit_exceeded says you went over.