claude-code - 💡(How to fix) Fix [BUG] Started to get API Error: 400 [1 comments, 2 participants]

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…
GitHub stats
anthropics/claude-code#55689Fetched 2026-05-03 04:47:03
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Timeline (top)
labeled ×4commented ×1

Error Message

API Error API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.170.content.3.text: cache_control cannot be set for empty text blocks"},"request_id":"req_011CaegKdvxdjKUQ7xw4E6dT"} hello

API Error API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"},"request_id":"req_011CaegLR3LuM65W8WXEhz59"} hello

API Error API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"},"request_id":"req_011CaegRDK3DdYvSDu4ES3fC"} hello

API Error API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"},"request_id":"req_011CaegcLXBeSMD4JYPQWbcL"}

Code Example

API Error
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.170.content.3.text: cache_control cannot be set for empty text blocks"},"request_id":"req_011CaegKdvxdjKUQ7xw4E6dT"}
hello

API Error
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"},"request_id":"req_011CaegLR3LuM65W8WXEhz59"}
hello

API Error
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"},"request_id":"req_011CaegRDK3DdYvSDu4ES3fC"}
hello

API Error
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"},"request_id":"req_011CaegcLXBeSMD4JYPQWbcL"}
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?

I suddenly started to get API errors in a Claude Code session

What Should Happen?

I should get a response instead of an API error

Error Messages/Logs

API Error
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.170.content.3.text: cache_control cannot be set for empty text blocks"},"request_id":"req_011CaegKdvxdjKUQ7xw4E6dT"}
hello

API Error
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"},"request_id":"req_011CaegLR3LuM65W8WXEhz59"}
hello

API Error
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"},"request_id":"req_011CaegRDK3DdYvSDu4ES3fC"}
hello

API Error
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages: text content blocks must be non-empty"},"request_id":"req_011CaegcLXBeSMD4JYPQWbcL"}

Steps to Reproduce

I tell it "hello" and it gives me an API error.

Claude Model

Opus

Is this a regression?

Yes, this worked in a previous version

Last Working Version

No response

Claude Code Version

the latest Windows version

Platform

Anthropic API

Operating System

Windows

Terminal/Shell

Other

Additional Information

No response

extent analysis

TL;DR

The issue can likely be resolved by ensuring that text content blocks in API requests are non-empty, as indicated by the error messages.

Guidance

  • Review the API request payload to verify that text content blocks contain valid, non-empty text.
  • Check the code that constructs the API request to ensure it handles empty text blocks correctly.
  • Consider adding input validation to prevent empty text blocks from being sent in API requests.
  • If the issue persists, try reproducing it with a minimal example to isolate the cause.

Example

No code snippet is provided as the issue does not include specific code details.

Notes

The error messages suggest that the issue is related to invalid API requests with empty text content blocks. However, without more information about the code or the specific API requests being made, it is difficult to provide a more detailed solution.

Recommendation

Apply workaround: Ensure that text content blocks in API requests are non-empty to prevent invalid request errors. This is based on the error messages provided, which indicate that empty text blocks are the cause of the issue.

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

claude-code - 💡(How to fix) Fix [BUG] Started to get API Error: 400 [1 comments, 2 participants]