You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Images exceeding 2000px are rejected by Anthropic API #12068
When pasting or reading images that exceed 2000 pixels in either dimension, Anthropic's API rejects the request with:
At least one of the image dimensions exceed max allowed size for many-image requests: 2000 pixels
This happens in two paths:
Clipboard paste (clipboard.ts) — images pasted from clipboard are sent raw without any size check
File read tool (read.ts) — images read via the Read tool are base64-encoded and sent as-is
Reproduction
Copy a large screenshot (e.g. 2560x1440) to clipboard
Paste it into OpenCode while using an Anthropic model
API returns dimension error
Expected Behavior
Images should be automatically resized to fit within Anthropic's limits before being sent to the API. A progressive resize strategy works well: attempt compression first, then resize to fit within 2000px, then reduce JPEG quality, and finally aggressive downscale to 1000px as a last resort.
Still hitting this on OpenCode 1.2.10 (macOS 15.7.4, ARM64).
Error:
Error: messages.5.content.297.image.source.base64.data: At least one of the image dimensions exceed max allowed size for many-image requests: 2000 pixels
When a conversation accumulates multiple images (screenshots, diagrams, etc.), OpenCode doesn't downscale them to fit Anthropic's multi-image limit (2000px per dimension). The API rejects the entire request.
OpenCode should auto-resize images to ≤2000px when the message contains multiple images before sending to the Anthropic API.
Reacted by Lucas Rueda, adam jones, Magoz and Tristan M.
It hooks into experimental.chat.messages.transform and automatically compresses oversized images (resize + recompress via Sharp) before the request reaches the API. Handles both paste/drag-drop and read-tool images.
Once a session breaks, you can export it to a .md file, fork to the last sent message, repeat it with an addendum like "EDIT: Here's what happened last time, carry on - <path>", and recover quickly
I adopted kargnas/opencode-large-image-optimizer for now, but I think a general error recovery mechanism for "bricked" chats would be really nice. This isn't the only time messages gets polluted with something illegal and forces a recovery like 1, and opencode should be able to handle this elegantly (or at least make the recovery more ergonomic)
Activity
github-actions commentedon Feb 4, 2026
This issue might be a duplicate of existing issues. Please check:
Feel free to ignore if this doesn't address your specific case.
lucasrueda commentedon Feb 6, 2026
this happens too much
neocody commentedon Mar 5, 2026
Still hitting this on OpenCode 1.2.10 (macOS 15.7.4, ARM64).
Error:
When a conversation accumulates multiple images (screenshots, diagrams, etc.), OpenCode doesn't downscale them to fit Anthropic's multi-image limit (2000px per dimension). The API rejects the entire request.
OpenCode should auto-resize images to ≤2000px when the message contains multiple images before sending to the Anthropic API.
JlMoreno00 commentedon Mar 18, 2026
I built a plugin that solves this — opencode-image-compact.
It hooks into
experimental.chat.messages.transformand automatically compresses oversized images (resize + recompress via Sharp) before the request reaches the API. Handles both paste/drag-drop and read-tool images.{ "plugin": ["opencode-image-compact"] }Zero-config, MIT licensed. Feedback welcome.
kargnas commentedon Mar 28, 2026
I tried above
opencode-image-compactbut it doesn't work with my claude auth.So I made by myself:
opencode.json
feat: add image optimizer plugin to prevent oversized image API errors
fadedlamp42 commentedon Apr 16, 2026
.mdfile, fork to the last sent message, repeat it with an addendum like "EDIT: Here's what happened last time, carry on -<path>", and recover quicklymessagesgets polluted with something illegal and forces a recovery like 1, andopencodeshould be able to handle this elegantly (or at least make the recovery more ergonomic)rekram1-node commentedon May 22, 2026
shouldnt happen anymore: 981e009
feat: add image optimizer plugin to prevent oversized image API errors