Skip to content

Images exceeding 2000px are rejected by Anthropic API #12068

@coleleavitt

Description

@coleleavitt

Bug

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:

  1. Clipboard paste (clipboard.ts) — images pasted from clipboard are sent raw without any size check
  2. File read tool (read.ts) — images read via the Read tool are base64-encoded and sent as-is

Reproduction

  1. Copy a large screenshot (e.g. 2560x1440) to clipboard
  2. Paste it into OpenCode while using an Anthropic model
  3. 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)

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions