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

Resolved 💬 2 comments Opened May 25, 2026 by nabdauto4 Closed May 29, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] 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.

View original on GitHub ↗

This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗