claude-code icon indicating copy to clipboard operation
claude-code copied to clipboard

API Error: 400 while using the Claude Code in my Terminal

Open MashoodAli-Official opened this issue 1 year ago • 30 comments

Hi there I have been facing the same error "API Error: 400" for the last three days. ⎿ API Error: 400 I have taken every single step to solve this issue, but nothing has worked. My Anthropic billing account is totally active and I have credits in my account to use it. The current Claude version is 0.2.49 (Claude Code).

Image

MashoodAli-Official avatar Mar 19 '25 06:03 MashoodAli-Official

@bcherny any ideas what is going wrong here?

wolffiex avatar Mar 20 '25 22:03 wolffiex

@bcherny any ideas what is going wrong here?

No idea till, i have try my best to solve this issue but nothing is working.

MashoodAli-Official avatar Mar 21 '25 09:03 MashoodAli-Official

I've noticed that I get this error when writing my own MCP server which returns annotations directed to the Assistant in the content field.

nmilian-onward avatar Mar 23 '25 17:03 nmilian-onward

I am having the same issue only with a particular repository. Works fine in other repos. I cannot fix broken context in this repo

Image

working here just fine Image

wickdninja avatar Mar 25 '25 02:03 wickdninja

I am closing this ticket as I have found the solution.

The issue was caused by the monthly credits limit settings. While the credit limit can be checked directly in the Anthropic console, that didn't work for me. Instead, I navigated to Workspace > Claude Code > Limits and adjusted or reset the monthly limit. Setting it to $100 resolved the issue, and everything started working properly. Moreover you can also delete and login again on your terminal with new API.

Image Image

MashoodAli-Official avatar Mar 27 '25 09:03 MashoodAli-Official

I am closing this ticket as I have found the solution.

The issue was caused by the monthly credits limit settings. While the credit limit can be checked directly in the Anthropic console, that didn't work for me. Instead, I navigated to Workspace > Claude Code > Limits and adjusted or reset the monthly limit. Setting it to $100 resolved the issue, and everything started working properly. Before doing this delete your old API and re-login with your new API in terminal.

Image Image

MashoodAli-Official avatar Mar 27 '25 09:03 MashoodAli-Official

still happens to me with claude max, so no limits there...

deafsquad avatar Jun 07 '25 22:06 deafsquad

happens to me as well. Usually after an hour or so.

 API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.231: `tool_use`
     ids were found without `tool_result` blocks immediately after: toolu_01V6qjweh9usykebYHx8HKYP. Each 
    `tool_use` block must have a corresponding `tool_result` block in the next message."}}

I cannot clear without starting a new session.

StuartFenton avatar Jun 08 '25 20:06 StuartFenton

happens to me as well. Usually after an hour or so.

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.231: tool_use ids were found without tool_result blocks immediately after: toolu_01V6qjweh9usykebYHx8HKYP. Each tool_use block must have a corresponding tool_result block in the next message."}} I cannot clear without starting a new session.

Yes facing exact same issue on Claude max plan.

fahimanwer avatar Jun 08 '25 23:06 fahimanwer

Same problem on max plan

RepairYourTech avatar Jun 10 '25 03:06 RepairYourTech

Exiting claude and restarting seems to fix it, something in the session breaks it randomly.

happens to me as well. Usually after an hour or so. API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.231: tool_use ids were found without tool_result blocks immediately after: toolu_01V6qjweh9usykebYHx8HKYP. Each tool_use block must have a corresponding tool_result block in the next message."}} I cannot clear without starting a new session.

Yes facing exact same issue on Claude max plan.

0x00-sys avatar Jun 11 '25 17:06 0x00-sys

+1, also getting this every few days on Max

jem-computer avatar Jun 12 '25 18:06 jem-computer

+1 same issue on Max

Image

zicochaos avatar Jun 15 '25 21:06 zicochaos

Also getting this error on Max:

API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.276: `tool_use` ids were found without `tool_result` blocks immediately after: 
     toolu_01234567890. Each `tool_use` block must have a corresponding `tool_result` block in the next message."}}

This happened multiple times, generally after some WebSearch/FetchContent calls. Claude-code then essentially becomes stuck, because it keeps retrying forever.

troberti avatar Jun 18 '25 14:06 troberti

@MashoodAli-Official could you pls reopen this as it seems to persist for many users, independent of billing,.

timfarkas avatar Jul 02 '25 16:07 timfarkas

This issue has multiple root causes, but we are working on driving down this error rate.

wolffiex avatar Jul 02 '25 16:07 wolffiex

Just got this error! Anybody got any solution or I need to start a new conversation?

arlucio avatar Jul 04 '25 06:07 arlucio

I started a new conversation and trying to solve the same issue I was having and seems like it got the same error when it got to the same part again, it was was checking a pretty big log of a docker container with more than 3400 lines.

Hope this helps solve the issue

arlucio avatar Jul 04 '25 06:07 arlucio

Same error here, appearing randomly

mareks76 avatar Jul 10 '25 17:07 mareks76

Same error, also appearing randomly

tobiwq avatar Jul 14 '25 21:07 tobiwq