[BUG] 413 "Request too large" error when referencing multiple files in Messages API despite being under documented limits

Resolved 💬 4 comments Opened Dec 12, 2025 by felix-locate Closed Feb 20, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

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/sdk v0.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

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.

What Should Happen?

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-07 beta, I have a 1 million token context window

I expected my 6.49 MB request with 271K tokens to succeed.

Error Messages/Logs

413 {"type":"error","error":{"type":"invalid_request_error","message":"Request too large"},"request_id":null}

Steps to Reproduce

  1. Upload 4 PDF files via /v1/files API:
  • 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
  1. 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"
          }
        }
      ]
    }
  ]
}
  1. Receive error:
413 {
  "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.

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)

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

2.0.64 (Claude Code)

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗