## TL;DR

For "invalid_request_error": 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.

```text
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.
2. Resize screenshots in your application before returning them in `tool_result`; the API will not do it for you.
3. 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 invalid_request_error 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.
