Skip to content

Images exceeding 2000px are rejected by Anthropic API #12068

Closed

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)

Activity

  1. github-actions commented on Feb 4, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    Feel free to ignore if this doesn't address your specific case.

  2. lucasrueda commented on Feb 6, 2026

    @lucasrueda

    this happens too much

  3. neocody commented on Mar 5, 2026

    @neocody

    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.

  4. JlMoreno00 commented on Mar 18, 2026

    @JlMoreno00

    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.

  5. kargnas commented on Mar 28, 2026

    @kargnas

    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"
      ]
    
  6. fadedlamp42 commented on Apr 16, 2026

    @fadedlamp42
    1. 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
    2. 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)
  7. rekram1-node commented on May 22, 2026

    @rekram1-node
    Contributor

    shouldnt happen anymore: 981e009

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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