claude-code - 💡(How to fix) Fix Claude Code web: image upload fails with API Error 400 'cache_control cannot be set for empty text blocks' on messages.2 in new session

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Error Message

API Error 400: cache_control cannot be set for empty text blocks This occurs on messages.2 in a brand new session, ruling out context length as the cause. The error appears to be triggered by an empty text block being generated alongside the image content block, with cache_control incorrectly applied to it. Result: API Error 400 immediately

Error Messages/Logs

API Error 400: messages.2.content.1.text: cache_control cannot be set for empty text blocks API Error 400: messages: text content blocks must be non-empty 5. Error appears immediately on messages.2

Fix Action

Fix / Workaround

When I upload an image in Claude Code web, the request immediately fails with: API Error 400: cache_control cannot be set for empty text blocks This occurs on messages.2 in a brand new session, ruling out context length as the cause. The error appears to be triggered by an empty text block being generated alongside the image content block, with cache_control incorrectly applied to it. Steps to reproduce: Open Claude Code web Start a new session Attach any image to a message and send Result: API Error 400 immediately Expected: Image uploads successfully Workarounds attempted: /compact, /clear, starting a new session — none resolved the issue. Model: Sonnet 4.6 High

Code Example

API Error 400: messages.2.content.1.text: cache_control cannot be set for empty text blocks

API Error 400: messages: text content blocks must be non-empty
RAW_BUFFERClick to expand / collapse

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

When I upload an image in Claude Code web, the request immediately fails with: API Error 400: cache_control cannot be set for empty text blocks This occurs on messages.2 in a brand new session, ruling out context length as the cause. The error appears to be triggered by an empty text block being generated alongside the image content block, with cache_control incorrectly applied to it. Steps to reproduce: Open Claude Code web Start a new session Attach any image to a message and send Result: API Error 400 immediately Expected: Image uploads successfully Workarounds attempted: /compact, /clear, starting a new session — none resolved the issue. Model: Sonnet 4.6 High

What Should Happen?

The image should be accepted and processed by the model without any API errors.

Error Messages/Logs

API Error 400: messages.2.content.1.text: cache_control cannot be set for empty text blocks

API Error 400: messages: text content blocks must be non-empty

Steps to Reproduce

  1. Open Claude Code web (not CLI)
  2. Start a brand new session
  3. Type any message and attach an image
  4. Send the message
  5. Error appears immediately on messages.2

Claude Model

Sonnet (default)

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

Web version — accessed via code.claude.com on May 25, 2026. Latest available version.

Platform

Other

Operating System

Windows

Terminal/Shell

Other

Additional Information

I am using Claude Code via the web interface at code.claude.com, not a local terminal or CLI installation. The API platform and terminal fields above were selected as "Other" as neither had a web option. Model was Sonnet 4.6 · High.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING