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

Resolved 💬 30 comments Opened Mar 19, 2025 by MashoodAli-Official Closed Aug 22, 2025
💡 Likely answer: A maintainer (wolffiex, collaborator) responded on this thread — see the highlighted reply below.

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).

<img width="616" alt="Image" src="https://github.com/user-attachments/assets/482c3bb0-7504-4dc1-a655-5943178207ab" />

View original on GitHub ↗

30 Comments

wolffiex collaborator · 1 year ago

@bcherny any ideas what is going wrong here?

MashoodAli-Official · 1 year ago
@bcherny any ideas what is going wrong here?

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

nmilian-onward · 1 year ago

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.

wickdninja · 1 year ago

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

MashoodAli-Official · 1 year ago

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 · 1 year ago

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

deafsquad · 1 year ago

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

StuartFenton · 1 year ago

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.

fahimanwer · 1 year ago
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.

RepairYourTech · 1 year ago

Same problem on max plan

0x00-sys · 1 year ago

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.
jem-computer · 1 year ago

+1, also getting this every few days on Max

zicochaos · 1 year ago

+1 same issue on Max

!Image

troberti · 1 year ago

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.

timfarkas · 1 year ago

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

wolffiex collaborator · 1 year ago

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

arlucio · 1 year ago

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

arlucio · 1 year ago

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

mareks76 · 1 year ago

Same error here, appearing randomly

tobiwq · 1 year ago

Same error, also appearing randomly

fsecgin · 1 year ago

just dropping a +1 here. i’m on the max plan too, so definitely not hitting any credit cap. saw the 400 error on a request that was somewhere around 14k tokens, but annoyingly can’t reproduce it now. maybe some internal limit? throwing this in case it helps triangulate.

harryfear · 12 months ago

Facing this, too. Had to start a new session, which destroyed context.

SergioKingOne · 11 months ago

same

michelsdev · 11 months ago

same here

⎿ API Error: 400
{"type":"error","error":{"type":"invalid_request_error","message":"messages.0.content.3:
unexpected tool_use_id found in tool_result blocks: toolu_015GWaNPsUS11miZmDUCb8Za. Each
tool_result block must have a corresponding tool_use block in the previous message."}}

relishev · 11 months ago

Also having same issue. waited for some time thinking maybe had tpm limit or so, but no...

resume

⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"The request body is not valid JSON:
no low surrogate in string: line 1 column 31459 (char 31458)"}}

resume

⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"The request body is not valid JSON:
no low surrogate in string: line 1 column 31459 (char 31458)"}}

/config

⎿ Set model to sonnet (claude-sonnet-4-20250514)

resume

⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"The request body is not valid JSON:
no low surrogate in string: line 1 column 31461 (char 31460)"}}

/config

⎿ Set model to opus (claude-opus-4-20250514)

/config

⎿ (no content)

resume

⎿ API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"The request body is not valid JSON:
no low surrogate in string: line 1 column 31459 (char 31458)"}}

Ayodukale · 11 months ago

also having the same issue ..

max86Git · 11 months ago

also having the same issue ..

API Error: 400 {"type":"error","error":{"type":"invalid_reque
st_error","message":"The request body is not valid JSON: no
low surrogate in string: line 1 column 98820 (char 98819)"}}

w1s3on3 · 11 months ago

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

igorkofman collaborator · 10 months ago

Closing this as stale (original bug report is against a pre 1.0 version) - please open a new issue for any new bugs.

github-actions[bot] · 10 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.