← Blog

Claude API Request Payload Size Limits Explained

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

If you've hit a 400 or 413 error while sending a large prompt, document, or image to the Claude API, you're running into one of several overlapping limits: the overall HTTP request body size, the model's context window (measured in tokens, not bytes), and per-file limits on images and documents. These aren't the same thing, and mixing them up is the most common reason developers get confused about "why did my request fail when it's not even that big."

The short answer: Anthropic's API caps the total request body at roughly 32MB per call (this covers your JSON payload including any base64-encoded images or files), while the context window — the combined size of your system prompt, message history, and expected output, measured in tokens — is the limit that actually bites most applications first. A 32MB request full of text is enormous (tens of millions of characters), but a 200K-token context window fills up fast once you're passing full PDFs, long conversation histories, or multiple embedded images.

What Actually Counts Toward the Limit

A Claude API request body includes:

Base64 encoding inflates binary data by roughly 33%, so a 3MB image becomes about 4MB of JSON text in your payload. If you're attaching several images or a multi-page PDF, that overhead adds up quickly and eats into both the request size cap and your token budget, since Claude converts image and document content into tokens internally.

Request Body Size vs. Context Window

These are two separate ceilings:

Request body size — a hard HTTP-level cap on how many bytes you can POST in a single call. This exists mostly to stop malformed or abusive requests, and in practice almost no legitimate text-only use case hits it.

Context window — the token budget for the model itself. Current Claude models support context windows up to 200K tokens (roughly 150,000 words of English text), with max_tokens reserving space for the response on top of your input. If your prompt plus your requested output exceeds the model's window, the request fails even if the raw byte size is small — this is the limit you'll actually run into with long documents, large codebases, or extended conversation history.

For images specifically, each image you send is converted into a number of tokens roughly proportional to its pixel dimensions. A very large, high-resolution image can consume more of your token budget than several pages of text, which is a common surprise for teams building vision-based tools.

Document and Image Specific Limits

On top of the general caps, there are per-item limits worth knowing:

Because these specific numbers shift as Anthropic ships new models, treat anything printed in a blog post (including this one) as a starting point and confirm against the current API reference before building limits into your own validation logic.

What Happens When You Exceed a Limit

You'll typically see one of these:

{
  "type": "error",
  "error": {
    "type": "invalid_request_error",
    "message": "prompt is too long"
  }
}

or an HTTP 413 Payload Too Large if you blow past the raw body size cap before the request even reaches model validation. Either way, the fix is the same: reduce what you're sending, not retry with backoff — this isn't a rate limit, it's a hard structural ceiling.

Practical Ways to Stay Under the Limits

Trim conversation history. Don't resend the entire chat log on every turn. Summarize older turns into a short recap and only keep the last few exchanges verbatim.

Chunk large documents. Split a long PDF or codebase into sections, process each separately, and combine results, rather than pasting the whole thing into one message.

Downscale images before encoding. Resize to the resolution you actually need for the task — a 4000x3000 photo rarely needs to stay that large for Claude to read text or describe a scene.

Reserve max_tokens deliberately. Don't set it to the maximum "just in case" — it counts against your context budget even before the model generates anything.

Stream instead of batching. For long-running generations, streaming responses lets you process output incrementally instead of holding a huge payload in memory. See /docs/streaming if you're routing through a wrapper that supports it.

If you're integrating Claude through SubToAPI, the underlying model limits are the same — SubToAPI doesn't change context windows or file size caps — but you get usage metadata per request in your dashboard, which makes it much easier to spot when a particular endpoint or feature is consistently sending oversized payloads before it turns into a production error. Check /docs/messages for the exact request shape and /docs/quickstart if you're setting this up for the first time.

Questions

Does the request size limit include my conversation history? Yes. The entire messages array counts toward both the request body size and the token-based context window, not just the latest message you're sending.

Will a large request return an error immediately or time out? You'll get an immediate 400-type error for context window overflows, or a 413 for raw body size violations — these fail fast rather than timing out, so you can catch and handle them in your request logic right away.

Can I increase my context window or payload limit on a paid plan? No — these limits are tied to the model itself, not your billing tier. Upgrading plans (including /pricing on SubToAPI) affects rate limits and seats, not the model's fixed context window or request size cap.

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 →