Image Upload Exceeds 5 MB Size Limit in API Request
Bug Description
i keep getting this for anything I type API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.
0.content.1.image.source.base64: image exceeds 5 MB maximum: 5607404 bytes > 5242880
bytes"}}
Environment Info
- Platform: darwin
- Terminal: WarpTerminal
- Version: 1.0.24
- Feedback ID: 179665c7-616b-4a83-b1d2-80438c4658d9
Errors
```jsonBug Description
i keep getting this for anything I type API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.
0.content.1.image.source.base64: image exceeds 5 MB maximum: 5607404 bytes > 5242880
bytes"}}
Environment Info
- Platform: darwin
- Terminal: WarpTerminal
- Version: 1.0.24
- Feedback ID: 179665c7-616b-4a83-b1d2-80438c4658d9
Errors
[{"error":"Error: Command failed: security find-generic-password -a $USER -w -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n at genericNodeError (node:internal/errors:983:15)\n at wrappedFn (node:internal/errors:537:14)\n at checkExecSyncError (node:child_process:882:11)\n at execSync (node:child_process:954:15)\n at HZ (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:659:3921)\n at file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:582:8863\n at Q (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:526:17199)\n at tJ (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:582:8009)\n at HS (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:582:7090)\n at T6 (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:582:11202)","timestamp":"2025-06-15T06:25:07.968Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.0.content.1.image.source.base64: image exceeds 5 MB maximum: 5607404 bytes > 5242880 bytes\"}}\n at h6.generate (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1329:12578)\n at Lw.makeStatusError (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1344:2082)\n at Lw.makeRequest (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1344:5257)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async ME2.K11.showErrors (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:22008)\n at async K11 (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:12203)\n at async ME2 (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:21854)\n at async file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:17103\n at async yt1 (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:5151)\n at async Fu (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:17073)","timestamp":"2025-06-15T06:26:10.388Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.0.content.1.image.source.base64: image exceeds 5 MB maximum: 5607404 bytes > 5242880 bytes\"}}\n at h6.generate (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1329:12578)\n at Lw.makeStatusError (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1344:2082)\n at Lw.makeRequest (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1344:5257)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async ME2.K11.showErrors (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:22008)\n at async K11 (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:12203)\n at async ME2 (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:21854)\n at async file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:17103\n at async yt1 (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:5151)\n at async Fu (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:17073)","timestamp":"2025-06-15T06:26:18.797Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.0.content.1.image.source.base64: image exceeds 5 MB maximum: 5607404 bytes > 5242880 bytes\"}}\n at h6.generate (file:///Users/<my-user>/.nvm/versions/node/v22.12.0/lib/
Note: Error logs were truncated.
[{"error":"Error: Command failed: security find-generic-password -a $USER -w -s \"Claude Code\"\nsecurity: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.\n\n at genericNodeError (node:internal/errors:983:15)\n at wrappedFn (node:internal/errors:537:14)\n at checkExecSyncError (node:child_process:882:11)\n at execSync (node:child_process:954:15)\n at HZ (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:659:3921)\n at file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:582:8863\n at Q (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:526:17199)\n at tJ (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:582:8009)\n at HS (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:582:7090)\n at T6 (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:582:11202)","timestamp":"2025-06-15T06:25:07.968Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.0.content.1.image.source.base64: image exceeds 5 MB maximum: 5607404 bytes > 5242880 bytes\"}}\n at h6.generate (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1329:12578)\n at Lw.makeStatusError (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1344:2082)\n at Lw.makeRequest (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1344:5257)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async ME2.K11.showErrors (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:22008)\n at async K11 (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:12203)\n at async ME2 (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:21854)\n at async file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:17103\n at async yt1 (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:5151)\n at async Fu (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:17073)","timestamp":"2025-06-15T06:26:10.388Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.0.content.1.image.source.base64: image exceeds 5 MB maximum: 5607404 bytes > 5242880 bytes\"}}\n at h6.generate (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1329:12578)\n at Lw.makeStatusError (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1344:2082)\n at Lw.makeRequest (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1344:5257)\n at process.processTicksAndRejections (node:internal/process/task_queues:105:5)\n at async ME2.K11.showErrors (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:22008)\n at async K11 (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:12203)\n at async ME2 (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:21854)\n at async file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:17103\n at async yt1 (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:5151)\n at async Fu (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/node_modules/@anthropic-ai/claude-code/cli.js:1698:17073)","timestamp":"2025-06-15T06:26:18.797Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.0.content.1.image.source.base64: image exceeds 5 MB maximum: 5607404 bytes > 5242880 bytes\"}}\n at h6.generate (file:///Users/felixflores/.nvm/versions/node/v22.12.0/lib/
**Note:** Error logs were truncated.
20 Comments
also getting this. I originally started in [session 1] with inputting an image that was too large.
I then scaled the image below the 5 mb and 8000 px requirement, but i kept getting the same error om [session 1].
then tried renaming the file, but still got the same error [session 1].
then spawned [session 2] fresh, and in this session it worked.
If you tap "esc" twice you can go back to a previous message before this happened and fork the conversation from there so you can continue
Same issue here
Additional Finding: Clipboard Caching Bug
I'm experiencing a related but distinct behavior that suggests a clipboard caching issue:
Symptoms
image exceeds 5 MB maximum: 5290848 bytes > 5242880 bytesKey Observation
The same 5MB error occurs regardless of the actual size of newly pasted images, suggesting Claude Code is:
Reproduction Steps
Environment
Workaround
Configure CleanShot to export JPEG at 80-90% quality instead of PNG to stay under 5MB limit.
Impact
This makes the existing 5MB issue worse because once triggered, the session is permanently broken for all image pastes, not just oversized ones. The cache should either:
BUMP on this. Once this happens, there is no way back to normal any more. You can add more messages in the chat without any image and it will stick with this error. You need to restart the claude cli
This helps in existing chats https://github.com/anthropics/claude-code/issues/2104#issuecomment-3063043033
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.
Still been happening to me
This should not be closed. It is still an issue. Still unable to recover from this. One issue mentioned using
/export, but this isn't available to me with vscode running in Ubuntu WSL 2.Workaround: Automated Session Repair for "Image Exceeds 5MB" Error
For anyone experiencing the persistent "image exceeds 5 MB maximum" error that continues even after you stop sending images, the issue is (appears to be) that the oversized Base64-encoded payload remains in your local .jsonl session history. Because Claude Code resends the conversation history with every new message, the session remains "corrupted" until that specific line is removed or replaced.
I have put together a comprehensive repair prompt and manual workflow that identifies these oversized lines (threshold: 5,242,880 bytes) and replaces them with a lightweight summary placeholder. This preserves the session integrity while allowing you to resume work without starting over.
This is working for me, on my system. I hope it works for you, too. That said, use with caution and make sure you create backups of the files before modification!
---
~~~
Fix my broken Claude Code session. I'm getting "image exceeds 5 MB maximum" errors that persist even for text-only messages.
Session selection (use the first option that applies):
Repair steps:
grep -n '"type":"image"' <file>sed -n '<N>p' <file> | wc -c{"type":"summary","summary":"[Image removed - exceeded 5MB limit]","uuid":"REMOVED-<line-number>"}Idempotency: Skip lines already containing "REMOVED-" in the uuid. If no oversized images found, report that the session appears clean.
Resuming the session:
After repair, the session can be resumed via:
claude --resume <session-id>Emergency Commands
Fix Oversized Image Bug
When I say "fix image bug" or "fix session images", run this repair:
.backupextensiongrep -n '"type":"image"' <file>for line numberssed -n '<N>p' <file> | wc -c{"type":"summary","summary":"[Image removed - exceeded 5MB limit]","uuid":"REMOVED-<line-number>"}claude --resume <session-id>Be idempotent. Skip lines with "REMOVED-" in uuid. Report if no oversized images found.
fix image bug
fix image bug for session 13348384-f296-4f89-a19d-f0d101b06831
fix image bug at /home/user/.claude/projects/-home-user-myproject/abc123.jsonl
fix image bug - list sessions
fix image bug in /custom/path/to/sessions/
1. Find your sessions
ls -la ~/.claude/projects/
2. Navigate to your project's folder (escape leading dash with --)
cd -- ~/.claude/projects/-home-username-projectname/
3. List sessions by size (largest first)
ls -lhS *.jsonl
4. Optionally, view session details from index
cat sessions-index.json | python3 -m json.tool
5. Backup
cp SESSIONID.jsonl SESSIONID.jsonl.backup
6. Find image lines and their sizes
grep -n '"type":"image"' SESSIONID.jsonl | cut -d: -f1 | while read line; do
size=$(sed -n "${line}p" SESSIONID.jsonl | wc -c)
if [ "$size" -gt 5242880 ]; then
echo "OVERSIZED - Line $line: $size bytes"
else
echo "OK - Line $line: $size bytes"
fi
done
7. Replace oversized lines with the summary placeholder
Note: Linux users use -i; macOS users use -i ''
Replace LINE_NUMBER with the actual number from step 6
Linux (GNU sed):
sed -i 'LINE_NUMBERs/.*/{"type":"summary","summary":"[Image removed - exceeded 5MB limit]","uuid":"REMOVED-LINE_NUMBER"}/' SESSIONID.jsonl
macOS (BSD sed):
sed -i '' 'LINE_NUMBERs/.*/{"type":"summary","summary":"[Image removed - exceeded 5MB limit]","uuid":"REMOVED-LINE_NUMBER"}/' SESSIONID.jsonl
8. Resume via terminal or reload VSCode window and use session picker
claude --resume SESSIONID
~~~
This is still happening. Ran Chris-Irving's script and the sessions are working again:
Session | Before | After | Saved
10a38b4b | 21MB | 7MB | 14MB
1bf9310d | 26MB | 14MB | 11MB
388b8601 | 11MB | 4MB | 6MB
4b6cf629 | 14MB | <1MB | 14MB
8d074528 | 14MB | <1MB | 14MB
b681caa2 | 9MB | 4MB | 5MB
efff2cea | 34MB | 19MB | 14MB
87f3fcec | 8MB | 2MB | 6MB
Adding a CLI (-p) case: the error is clear, but what hurts is that it leaves the session in a broken state. Even compaction failed afterward with the same 400 error.
Impact: after the error appears, the session doesn’t recover; compaction and retries both fail.
i have been getting these msg in prompts over the past couple of days
I found an easy solution which worked just fine for me, i click on my very last input (before the bug appeared) and click "Message Actions --> Fork Conversation from here", usually its alot easier to start from that point again rather than starting a new conversation. Let me know if this works for you. Have a nice one
Since losing conversation history was a recurring problem for me, I built a bash dashboard to track all Claude Code operational files (CLAUDE.md, MEMORY.md, conversation logs) across projects. It helps you see what Claude knows per project and clean up old session logs.
Zero dependencies, single script: https://github.com/sarob/claude-ops
Not all heroes wear capes
Its a simple solution. Thx! I also created a shell script to monitor and clear conversation logs. ~ SeanOn Feb 17, 2026, at 12:11, Rob @.***> wrote:Robvienne left a comment (anthropics/claude-code#2104)
I found an easy solution which worked just fine for me, i click on my very last input (before the bug appeared) and click "Message Actions --> Fork Conversation from here", usually its alot easier to start from that point again rather than starting a new conversation. Let me know if this works for you. Have a nice one
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you commented.Message ID: @.***>
Fix script and steps here
This is a persistent and annoying issue. Several bugs and feature requests are related to this and so far no progress from Antrhopic
Does anyone actually work at this company who looks at GitHub?