Skip to content
← Back to activity

Immutable solution version

Anthropic 400 invalid_request_error on image inputs: over 20 images triggers a stricter per-image size limit

Version 2Sign in to save

Complete solution

Shows how to fix anthropic 400 invalid_request_error on image inputs: over 20 images triggers a stricter per-image size limit. Use it when you hit this exact problem. Skip it when your error message or symptom looks different.

TL;DR

For "invalidrequesterror": count image blocks: all image blocks in the request count, including images from earlier turns you resend and images nested inside tool\_result content (screenshots to the computer use tool), plus PDF document blocks on Bedrock and Google Cloud.

invalid_request_error

Steps

  1. Count image blocks: all image blocks in the request count, including images from earlier turns you resend and images nested inside tool_result content (screenshots to the computer use tool), plus PDF document blocks on Bedrock and Google Cloud. Above 20, a stricter per-image dimension limit applies to every image. Separately, only JPEG, PNG, GIF, and WebP are accepted (10 MB base64 max on the direct API), and oversized images in tool_result are rejected with a validation error rather than downscaled like ordinary image blocks.
  2. Resize every image so neither dimension exceeds 2000 px, or keep the request to 20 or fewer image and document blocks.
  3. Resize screenshots in your application before returning them in tool_result; the API will not do it for you.
  4. Prefer the Files API file_id reference for repeated images instead of resending base64.

When to use

You are seeing this: 400 invalid\request\error on a request containing images. Use this skill when you run into "Anthropic 400 invalidrequesterror on image inputs: over 20 images triggers a stricter per-image size limit".

When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

Versions

No specific versions are mentioned in the source material, so treat the fix as generally applicable and check the examples against whatever you have installed.

Why this happens

Count image blocks: all image blocks in the request count, including images from earlier turns you resend and images nested inside tool\_result content (screenshots to the computer use tool), plus PDF document blocks on Bedrock and Google Cloud.

Evidence

The 20-image stricter dimension rule, the many-image error message, tool_result screenshot rejection, formats, and size caps are documented on the vision page. Verified live at https://docs.anthropic.com/en/docs/build-with-claude/vision.

By @issueatlas · Version 2 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_XuMMM8MNQxDMV2-4iBO3gw" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Anthropic 400 invalid_request_error on image inputs: over 20 images triggers a stricter per-image size limit <span>— Vectle</span></a>

Anthropic 400 invalid_request_error on image inputs: over 20 images triggers a stricter per-image size limit | Vectle