Fix guides · Claude Code, Cursor ·
Fix Claude Code / Cursor HTTP 413 Request Entity Too Large
HTTP 413 Request Entity Too Large
Claude Code or Cursor returns HTTP 413 Request Entity Too Large when the request body sent to the AI provider exceeds the provider size limit. This happens when the combined prompt content and tool use block output are too large. The fix is to reduce the request body size by trimming context and reducing tool use block output.
Common causes – and how to tell which one you have
1. Large prompt including too much code context
How to tell: The error occurs after feeding a large codebase or many files to Claude Code/Cursor. The combined prompt content exceeds the provider size limit in bytes.
Fix: Trim the code context to the minimum needed for the task. Remove files or functions not directly relevant. Split large tasks into smaller chunks.
2. Many tool_use/tool_result blocks with large output
How to tell: One tool_result block returns an enormous response (a full file dump or long command output) that dominates the payload.
Fix: If one tool_result block is enormous, have the tool summarise or narrow it first — e.g. read only the relevant line range, or grep instead of cat. If the problem is accumulated conversation history, Claude Code's /clear and /compact reduce that; in Cursor, start a new chat.
3. Base64-encoded files in the request
How to tell: You are including file contents base64-encoded in the prompt. Base64 always inflates data by about 33%. Even a single large file can exceed the limit.
Fix: Send only the relevant text instead of whole files. For supported file types (PDFs, images, plain text), use the Anthropic Files API (upload once, reference by file ID) or the provider file upload mechanism instead of embedding base64. For unsupported binary files, extract the relevant text first — do not embed the raw binary. Do not gzip or zip before base64-encoding — the model cannot read compressed bytes.
How to fix it
- Check the error message in your terminal or Claude Code/Cursor output: it should say HTTP 413 Request Entity Too Large.
- Identify what is causing the large payload: large code context, many tool_use/tool_result blocks with large output, or base64-encoded file contents.
- Reduce the request body: trim the code context to the minimum needed for the task. Remove files or functions not directly relevant. In Claude Code, use /clear or /compact to reduce context. In Cursor, start a new chat session.
- Reduce tool use block output size: use summaries instead of full file contents when possible. Split the request into smaller chunks.
- If including files: send only the relevant text, not whole files. For supported file types (PDFs, images, plain text), use the Anthropic Files API (upload once, reference by file ID) or the provider file upload mechanism instead of embedding base64. For unsupported binary files, you cannot include them directly — extract the relevant text first.
- Restart Claude Code/Cursor and retry the request with the reduced payload.
Using Lovable, Bolt or v0?
In Claude Code or Cursor, if you hit HTTP 413, first estimate the request body size. Then trim the code context, reduce the number of tool use blocks, and avoid including large file contents base64-encoded without compression. Ask the tool to retry with a smaller prompt. If you regularly hit this limit, check the provider documentation for the exact limit.
Using Cursor, Claude Code or Windsurf?
Ask the agent to estimate the request body size before making the request. If it exceeds the provider limit, have it trim the context to the essentials, remove unnecessary tool_use/tool_result blocks, and retry. Never hardcode a workaround that silently returns incomplete results — the error exists for a reason.
The “fix” to avoid
Agents often "fix" this by reducing temperature, adding "\n\n" between blocks, or ignoring the error and accepting incomplete output. These do not address the root cause (payload too large). The error must be resolved by reducing the actual payload size.
Copy-paste fix prompt for your AI coding tool
Paste this into Cursor, Claude Code, Lovable or Bolt:
My Claude Code / Cursor request fails with HTTP 413 Request Entity Too Large. Check in this order: 1) Is the total request body too large in bytes (combined prompt content + tool_result block output)? 2) Are there tool_result blocks returning huge outputs (full file dumps, long command output)? 3) Is a file being embedded base64 in the prompt? Fix by trimming code context, splitting the task, summarising large tool_result output instead of pasting it whole, and avoiding base64 file embeddings. For files the provider supports, use the Files API (upload once, reference by file ID). Then retry with the reduced payload.
Questions people ask
Why does it work with smaller prompts but not larger ones?
The AI provider imposes a hard limit on the total request body size (prompt + tool use block contents). Exceeding it returns 413 instead of processing the request.
Can I increase the size limit myself?
The limit is set by the provider for the API endpoint and is not configurable by users. Check the provider documentation for the exact limit for the endpoint you are using.
Does this happen with Claude Opus too?
Yes. All Anthropic models (Haiku, Sonnet, Opus) have request body size limits. The limit is set by the provider and is not configurable by users.