Claude API · Caching, batches and tokens

Submit a batch

Process many requests asynchronously at half the price. Each request needs a custom_id.

from anthropic.types.message_create_params import MessageCreateParamsNonStreaming
from anthropic.types.messages.batch_create_params import Request

batch = client.messages.batches.create(requests=[
    Request(
        custom_id=f"request-{i}",
        params=MessageCreateParamsNonStreaming(
            model="claude-opus-5-5",
            max_tokens=16000,
            messages=[{"role": "user", "content": prompt}],
        ),
    )
    for i, prompt in enumerate(prompts)
])

Official Claude API documentation

More caching, batches and tokens commands

All caching, batches and tokens commands · Claude API cheatsheet

Was this page helpful?