payload_too_large
The message text is shown in the example below.
| HTTP status | 413 |
type | invalid_request_error |
| Retry? | No, not unchanged |
| Status | In the public catalog (error-envelope.ts) |
| Extra fields | max_bytes |
When it happens
The body is over 2,000,000 bytes, or the model service refused it as too large.
Example
{
"error": {
"type": "invalid_request_error",
"code": "payload_too_large",
"message": "The request is too large.",
"param": null,
"request_id": "req_6f1c2a9e0b7d4c3a8e5f1b2d",
"max_bytes": 2000000
}
}How to fix it
- Upload large documents once through the Files API and pass the file id rather than inline content.
- Send images by URL rather than base64 where you can.
- Trim old turns.
Detect it in code
err = resp.json().get("error", {})
if resp.status_code == 413 and err.get("code") == "payload_too_large":
log.warning("%s (%s)", err["message"], err["request_id"]) # fix the request; do not retry unchangedRelated
Was this page helpful?