GeezerVison is showing github.com — Images exceeding 2000px are rejected by Anthropic API · Issue #12068 · anomalyco/opencode
Images exceeding 2000px are rejected by Anthropic API #12068DescriptionBug
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.
Environment
- OpenCode latest on
dev
- Any Anthropic model (Claude Sonnet, Opus, etc.)
- Any OS (macOS, Linux, Windows)
Reacted by MinmoTech, adam jones, lukts30, Tommy D. Rossi, SHL0MS and yaronshanisima Activitygithub-actions commented on 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 commented on Feb 6, 2026 neocody commented on Mar 5, 2026 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. JlMoreno00 commented on Mar 18, 2026 I built a plugin that solves this — opencode-image-compact.
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.
bun add opencode-image-compact
{ "plugin": ["opencode-image-compact"] }
Zero-config, MIT licensed. Feedback welcome. kargnas commented on Mar 28, 2026 I tried above opencode-image-compact but it doesn't work with my claude auth.
So I made by myself:
opencode.json
"plugin": [
"opencode-large-image-optimizer@latest"
]
Reacted by Cody and Peter Gomez fadedlamp42 commented on Apr 16, 2026
- 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)
rekram1-node commented on May 22, 2026
MetadataMetadataDevelopmentNo branches or pull requestsIssue actions
|