Claude Code API Error 413 “Request Too Large”: What Causes It

Claude Code API Error 413 “Request Too Large”: What Causes It

If Claude Code shows “Request too large (max 32MB)”, the raw data it tried to send to the Claude API was bigger than 32 megabytes, so the API turned it away before reading a single word. A Claude Code request too large error almost always comes from a huge paste, a pile of screenshots or PDFs, or big tool output building up in one conversation.

Your files and project are fine. Only that one request was refused, and the message itself tells you which fix will work.

Here is the short fix list:

  • If the message says “compacting cannot make it fit”, press Esc twice to go back past the turn that added the big content, or run /clear.
  • Otherwise, run /compact, which drops the images and attachments that piled up.
  • Next time, give Claude the file’s path instead of pasting it, so it can read the file in small chunks.
  • For a big PDF or image, shrink it or ask Claude to read only a page range.

This guide is part of our help series. Browse all our Claude Code tutorials for more fixes and how-tos.

Tested with Claude Code v2.1.328 on macOS on November 19, 2026. Pushing more than 32MB at the API just to show the error would be slow and wasteful, so the error text below comes from Anthropic’s official error reference, shown in highlighted screenshots. Every fix, though, we ran for real in a demo folder holding 42MB of test files, and every terminal capture is genuine.

Request Too Large in Claude Code: Quick Summary

QuestionShort answer
Message you seeRequest too large (max 32MB), plus a hint about what to do
HTTP status413, which the Claude API calls request_too_large
What it meansThe raw request body passed 32MB before tokens were even counted
Usual causesBig pastes, many images or PDFs, huge tool output
Fastest fix/compact, or Esc twice if compacting can’t help
Lasting fixPoint Claude at file paths instead of pasting contents
Same as “Prompt is too long”?No, that one is about tokens and the context window
Are files lost?No, only the request was rejected
Decision diagram for the Claude Code request too large error: if the message says compacting cannot make it fit press Esc twice or run /clear, if many images or files were added run /compact, if you pasted a huge file give the path instead, and for a big PDF or image shrink it or read page ranges
Which fix to try first when Claude Code says the request is too large.

What Causes the Claude Code Request Too Large Error

Every time you send a message, Claude Code sends the API the whole conversation so far, not just your newest line. That includes your earlier prompts, Claude’s replies, tool results, and any images, PDFs or pasted text you added along the way.

The Claude API puts a hard cap of 32MB on that request body. Anthropic’s error reference says the raw request “exceeded the API’s 32MB limit before tokenization”, usually because of large pasted content, tool results or attachments. Anthropic’s API error list names the same thing status 413, request_too_large.

Claude Code error reference page, Request too large section, with the Request too large max 32MB error message highlighted
The official entry for this error in Anthropic’s Claude Code error reference.

The Exact Error Messages

The general form, which you also get when you connect through a proxy, gateway or cloud provider, reads like this:

Request too large (max 32MB). Accumulated images and attachments in the conversation pushed the request over the limit. Run /compact, or double press esc to go back and remove attachments.

When Claude Code talks straight to the Claude API, it measures the conversation and picks one of two more specific forms:

  • Request too large (max 32MB; 20.1MB of about 33.4MB is images or documents). Images or documents pushed the request over, and Claude Code retries on its own with them stripped out.
  • Request too large for the API's 32MB request limit. The messages alone are too big, so the message adds “compacting cannot make it fit” and Claude Code doesn’t retry.

In non-interactive mode, such as claude -p, that second form tells you to reduce the input or start a new session instead. The numbers in the first form change with your conversation; 20.1MB and 33.4MB are just the docs’ example.

Megabytes, Not Tokens

This is the part that confuses most people. The 32MB check happens before the API counts tokens, so it’s about raw file size. A few big screenshots can weigh more than a whole novel’s worth of text.

That makes it a different problem from the prompt too long error, which means the conversation has more tokens than the model’s context window. You can hit either one, and the fixes overlap, but the cause is not the same.

Flow diagram showing two size limits in Claude Code: the whole conversation is checked against 32MB first and fails with Request too large, then a request under 32MB is checked against the context window in tokens and fails with Prompt is too long
The 32MB size check comes first; the token-based context window check comes after.

Why It Shows Up Late in a Session

Because the whole history is sent each turn, images and attachments add up. You might attach ten screenshots over an hour, each one fine on its own, and only the eleventh turn crosses 32MB.

The docs note that before v2.1.212, a conversation with enough stored images failed on every single turn after that. Newer versions strip old images and retry, and since v2.1.229 the message only suggests attachment fixes when they can actually help. That’s a good reason to stay updated.

How to Fix “Request Too Large” in Claude Code

Anthropic’s error reference gives a short “What to do” list for this error. We tried each step in a throwaway demo project with a 19MB log file and a 23MB CSV export, 42MB together, which is more than the API would accept in one request.

Claude Code error reference, Request too large What to do list highlighted: press Esc twice or run /clear when compacting cannot make it fit, otherwise run /compact, reference large files by path, and see Image was too large for images
Anthropic’s official fix list for the request too large error.
Terminal showing claude --version 2.1.328 and du output: logs/app.log is 19M, data/orders-export.csv is 23M, 42M in total, highlighted as over the 32MB cap
Our demo files: 42MB together, too big to send in a single request.

Fix 1: Press Esc Twice or Run /clear

If your message says “compacting cannot make it fit”, the content in the conversation itself is over the limit. Summarizing won’t shrink it enough, so you need to remove the turn that added it.

Press Esc twice on an empty prompt. Claude Code opens the Rewind menu, which lists your earlier prompts so you can jump back to a point before the big paste or attachment. Pick that point, press Enter, and resend a smaller version.

Claude Code Rewind menu opened with Esc twice, listing earlier prompts to restore the conversation to the point before them, with one prompt highlighted
Esc twice opens Rewind, where you pick the turn to go back to.

If you don’t need anything from the conversation, /clear starts fresh in the same window. Our clear vs compact guide explains what each choice keeps.

Fix 2: Run /compact to Drop Old Attachments

If the message doesn’t say “compacting cannot make it fit”, run /compact. The docs say it drops accumulated images and attachments, and it replaces older turns with a short summary.

Claude Code terminal after running /compact, showing Compacted with ctrl+o to see full summary, highlighted as older turns summarized
A real /compact run in our demo session: older turns are summarized.

You can add a focus to tell it what to keep, for example /compact keep only the plan and the latest diff. If compacting itself seems to hang, see our fix for stuck compacting.

Fix 3: Give Claude the Path Instead of Pasting

This is the fix that stops the error from coming back. When you paste a file, every byte goes into the conversation and gets sent again on every later turn.

Claude Code shows a big paste as a single placeholder line, which makes it easy to forget how much is inside. Our paste of 3,000 log lines collapsed to one short tag:

Claude Code prompt box showing a large paste collapsed into Pasted text #1 +2999 lines, highlighted as 3,000 log lines in one paste
A 3,000-line paste looks tiny in the prompt box, but every line still gets sent.

We cleared that paste without sending it. Instead, we named the file and told Claude how to look at it. It ran a search on the 19MB log and sent back only the answer:

Claude Code session where the prompt asks to grep logs/app.log instead of pasting it; Claude searched for 1 pattern and reported 11,706 ERROR lines and showed the first three
Claude searched the 19MB file with grep and returned three lines, not the whole log.

You can also ask for a line range. The Read tool pulls in only what you ask for:

Claude Code session reading only lines 1-20 of logs/app.log with the Read tool and answering that none of those 20 lines are WARN
Asking for lines 1-20 keeps a huge file out of the conversation.

Fix 4: Shrink Big PDFs and Images

PDFs and images have their own limits, and they often lead to this error when you attach several. The docs list a PDF cap of 100 pages and 20MB, and suggest reading a page range or turning the PDF into text with a tool like pdftotext.

Claude Code error reference, PDF errors section with PDF too large max 100 pages 20MB highlighted, plus the advice to read a page range or extract text with pdftotext
The official PDF limits and fixes from the Claude Code error reference.

For screenshots, crop to the part that matters and save as PNG or JPEG before attaching. Our test of reading PDFs shows how page ranges work in practice.

Fix 5: Check What Fills the Session With /context

Run /context to see a breakdown of the conversation. It counts tokens, not megabytes, so it won’t show the 32MB figure, but a large Messages row tells you a lot of content has built up.

Claude Code /context output showing the model, 37.9k of 1m tokens used, and the usage by category with the Messages row highlighted as your turns and files
The Messages row in /context holds your turns, files and tool output.

Our context window guide walks through every row of this screen.

Fix 6: Update Claude Code

Several fixes for this error landed in recent versions, including automatic retries with images stripped and clearer messages. Run claude update, then check with claude --version.

claude update
claude --version

Real Examples of What Triggers It

These are the situations the docs point to, in plain terms:

SituationWhy it gets too largeBest fix
Pasting a whole log or data exportAll of it is sent on every turnEsc twice, then name the path
Many screenshots in one long chatImages pile up in the history/compact
Several big PDFs attachedDocuments count toward 32MBPage ranges or pdftotext
A tool dumped huge outputTool results stay in the history/compact or /clear
Using a proxy or cloud providerOnly the general message is shownSame steps, starting with /compact

If you can name the file, don’t paste the file. A path costs a few bytes; a paste costs every byte, every turn.

Try It Yourself

Make a demo folder with one big text file, then ask Claude to work on it without pasting anything. This prompt keeps the request small no matter how big the file is:

logs/app.log is very large, so I won't paste it. Don't read the whole file:
use grep to count the ERROR lines, then show only the first 3 of them.

Then try /context to see how little the Messages row grew, and Esc twice to see the Rewind menu. It’s a quick way to build the habit before a real 32MB problem shows up.

Common Mistakes

  • Running /compact again and again when the message says “compacting cannot make it fit”. It won’t help; go back with Esc twice or use /clear.
  • Re-pasting the same big file after the error. The new paste trips the same limit.
  • Assuming a big context window means big requests are fine. The 32MB cap applies even when the model has plenty of token room left.
  • Attaching full-size screenshots when a small crop would do.
  • Mixing up this error with output token limits, which are about the size of Claude’s reply, not your request.

Pro Tips

  • Start long image-heavy tasks in a fresh session, and /compact between stages.
  • Ask Claude to write big results to a file instead of printing them in the chat.
  • For huge data files, ask for a summary first, such as column names, row counts or the top errors.
  • Use head, grep or line ranges in your prompt so Claude never needs the whole file at once.
  • Keep a link to our common errors guide handy for the other messages you might meet.

Claude Code Request Too Large Cheat Sheet

Cheat sheet for the Claude Code request too large error: Esc Esc, /compact, /clear and claude update to fix it now, plus naming the path, asking for a line range, grep or head and /context to stop it coming back
The quick fixes and the habits that prevent the error, on one card.

You can read Anthropic’s own entries in the Claude Code error reference and the troubleshooting guide. For more commands, our commands cheat sheet has them all on one page.

Frequently Asked Questions

What is the size limit for a Claude Code request?

32MB for the raw request body sent to the Claude API. That covers the whole conversation, including images, documents and tool results, not just your latest message.

Is “Request too large” the same as “Prompt is too long”?

No. Request too large is about megabytes and is checked first. Prompt is too long is about tokens and the model’s context window.

Why does /compact not fix it?

If the message says “compacting cannot make it fit”, the messages themselves are over 32MB. Press Esc twice to go back before the big content, or run /clear.

Does it cost me usage?

Anthropic’s API docs say that on the first-party Claude API this error is returned before the request reaches the API servers, so the oversized request never gets a reply. Your next, smaller message is a normal request.

Did I lose my work?

No. Only the request was refused. Your files are untouched, and the conversation stays as it was until you compact, rewind or clear it.

Conclusion

The Claude Code request too large error means the conversation Claude Code tried to send passed the Claude API’s 32MB cap, the 413 request_too_large limit, usually because of big pastes, stacked-up images and PDFs, or huge tool output. Press Esc twice or run /clear when the message says compacting can’t help, run /compact in every other case, and give Claude file paths, line ranges and search commands instead of pasting whole files so it never builds up again. To see what else Claude AI can do, browse the rest of our guides.

Newsletter

New AI tools in your inbox

The best new tools and the AI news that matters, in one short email. Unsubscribe any time.

Free · No spam · Unsubscribe any time

✓ Looks like you’re subscribed

Loading Google’s sign-up form…

Looks like you’re already subscribed

Thanks for reading! New AI tools and the AI news that matters will land in your inbox.

Not subscribed yet? Refresh the page to load the sign-up form.

The sign-up form couldn’t load. If you use an ad or content blocker, allow news.google.com and reload the page.

Free instant check before you pay. Takes a few seconds.

Scroll to Top