Beginner Q&A: API returned 413, is my prompt too long or my file too big?
HTTP 413 Content Too Large means the request content exceeded a server-defined limit. It concerns the byte size of the whole request body, not the model's context tokens. It is common with large image uploads, base64-embedded files and very long chat histories. Find which hop rejected it, then shrink the request or switch to a file transfer method.
Short answer
413 Content Too Large means the request content exceeded limits defined by the server. The server may close the connection or return a Retry-After header. Before RFC 9110 the status was named Payload Too Large, which is still widely used.12
The key point: 413 is about the byte size of the request body, not the model's context window. A request can be well within token limits and still be rejected with 413 by some layer because it carries a large base64 image. Conversely, a small request in bytes can exceed the token limit and get a different error, usually a 400 with a specific message.
Q1: Which requests hit 413 most?
- Base64-embedded images or files: base64 grows data by about a third, so a multi-megabyte original can far exceed a gateway's default limit once encoded.
- Very long multi-turn chats: putting full history, tool results and long documents into
messagesmakes the JSON grow fast. - Multiple reference images in one request: each base64-encoded, adding up.
- Large multipart uploads: the file alone exceeds some layer's upload limit.
Q2: Who returned the 413?
A request may pass through a local proxy, a corporate gateway, a relay gateway and the upstream service. Each layer may have its own body limit, and error formats differ.
How to tell:
- Look at the response body format: an API-style JSON error or a web server's HTML error page. An HTML page usually means a proxy or gateway rejected it.
- Look at the timing: 413 often comes back quickly, right after the server reads the headers or part of the body. A long wait before the error points to something else.
- Bisect: halve the body and resend to find the approximate limit.
Q3: How do I fix it?
In order of priority:
- Compress the input: scale images to the resolution you actually need before encoding; summarize or split long documents.
- Pass reference images by URL: if the endpoint accepts reference URLs, let the server download them, leaving just a link in the body. The URL must be anonymously downloadable by the server; SalpX docs state this explicitly, and base64 remains the fallback if unsure.3
- Trim chat history: keep only turns relevant to the current task and compress earlier content into a summary.
- Split the request: process multiple images or files in batches.
- Adjust limits on layers you own: if your own reverse proxy or gateway returned the 413, raise its body limit to what you actually need, but not without bound, to avoid abuse.
Q4: Should 413 be retried automatically?
Retrying an unchanged request is pointless; the same size gets the same result. MDN notes the server may return Retry-After, which usually means the limit is temporary;1 but for API calls, most 413s are fixed limits, so the fix is a smaller request, not waiting.
How it differs from 431 and 400
431: request headers too large, such as too many cookies or custom headers.413: request body too large, such as base64 files or very long JSON.400(with a context-limit message): the bytes may be small, but tokens exceed the model's context window.
The fixes differ completely: remove headers for 431, shrink the body for 413, and trim content or pick a longer-context model for context overflow.
In one line
413 measures bytes, not tokens. Find which layer rejected the request, then choose from compressing, using URLs, trimming history or splitting requests. Do not keep retrying the same request.
Sources & attribution
This article references the public materials listed below. Analysis and wording are SalpX's own; quoted material remains the property of its original authors and publishers.
- 413 Content Too Large - HTTP — MDN Web Docs · accessed 2026-11-28Note:MDN: 413 means the request entity exceeded server-defined limits; the server may close the connection or send Retry-After. It was called Payload Too Large before RFC 9110.
- RFC 9110: HTTP Semantics — IETF / RFC Editor · accessed 2026-11-28Note:The HTTP Semantics standard; section 15.5 defines client error codes including 401, 403, 413 and 415.
- SalpX API Reference — SalpX · accessed 2026-11-28Note:SalpX official docs: Base URL, Bearer auth, image size tiers, 4K model names, the clamp response header, and integration notes such as a 300s+ timeout, a 10 MB response budget and publicly downloadable reference images.
One key for Claude, GPT and 50+ models
The SalpX gateway is OpenAI-SDK compatible. Point base_url at https://www.salpx.com/v1 and you are done.