-
Notifications
You must be signed in to change notification settings - Fork 423
Description
413 "Request too large" error when referencing multiple files in Messages API despite being under documented limits
Description
I'm encountering a 413 Request too large error when using the /v1/messages API with multiple files uploaded via /v1/files API, despite being well under all documented limits.
Configuration
- Beta flags:
context-1m-2025-08-07,files-api-2025-04-14 - Model:
claude-sonnet-4-20250514 - SDK:
@anthropic-ai/sdkv0.68.0
The Issue
When referencing 4 PDF files in a single message request, I receive a 413 error even though:
- ✅ Total PDF file size: 6.49 MB (well under any documented payload limit)
- ✅ HTTP request payload: ~18 KB (just JSON with file references)
- ✅ Token usage: ~271K tokens (well under 1M context window)
- ✅ Individual files: All under 100 MB per-file limit
- ✅ Each file uploads successfully to
/v1/files
Reproduction Steps
-
Upload 4 PDF files via
/v1/filesAPI:- File 1: 1.76 MB (87 pages)
- File 2: 3.44 MB (20 pages)
- File 3: 951 KB (8 pages)
- File 4: 364 KB (4 pages)
- Total: 6.49 MB, 119 pages
-
Send a message referencing all 4 files:
{
"model": "claude-sonnet-4-20250514",
"max_tokens": 1024,
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "Summarize these files"
},
{
"type": "document",
"source": {
"type": "file",
"file_id": "file_011CVynXuw9EEpoFvNbA9La9"
}
},
{
"type": "document",
"source": {
"type": "file",
"file_id": "file_011CVynXz3hWHxVDkiZSKJeT"
}
},
{
"type": "document",
"source": {
"type": "file",
"file_id": "file_011CVyntPf4PXtRDZym7sqcD"
}
},
{
"type": "document",
"source": {
"type": "file",
"file_id": "file_011CVyo1fyHG9DSBNDD5TgSL"
}
}
]
}
]
}- Receive error:
{
"type": "error",
"error": {
"type": "invalid_request_error",
"message": "Request too large"
},
"request_id": null
}
Testing Results
Through systematic testing, I've identified an undocumented threshold:
| Test | Files | Total Size | Status | Tokens Used |
|---|---|---|---|---|
| 1 | 1 file | 3.44 MB | ✅ Success | 238,708 |
| 2 | 2 files | 5.2 MB | ✅ Success | 250,846 |
| 3 | 3 files | 6.13 MB | ✅ Success | 270,752 |
| 4 | 4 files | 6.49 MB | ❌ 413 Error | N/A |
| 5 | 3 files | 8.65 MB | ❌ 413 Error | N/A |
Finding: There appears to be an undocumented limit of ~6.3 MB on the combined size of all files referenced in a single Messages API request.
Expected Behavior
Based on the documentation:
- Files API supports up to 100 MB per file
- Messages API supports up to 32 MB total request size
- With
context-1m-2025-08-07beta, I have a 1 million token context window
I expected my 6.49 MB request with 271K tokens to succeed.
Actual Behavior
Requests fail with 413 when the combined referenced file size exceeds ~6.3 MB, regardless of:
- The actual HTTP payload size (~18 KB)
- Token usage (well under 1M limit)
- Individual file sizes (all under 100 MB)
Environment
- Platform: Node.js
- SDK Version:
@anthropic-ai/sdk@0.68.0 - Request method: REST API via proxy server
Additional Context
The error occurs during the file processing/text extraction phase on Anthropic's side, not during HTTP transmission. The 413 error suggests a resource constraint when processing multiple large PDFs simultaneously, separate from token limits.