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" />
30 Comments
@bcherny any ideas what is going wrong here?
No idea till, i have try my best to solve this issue but nothing is working.
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.
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
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
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
still happens to me with claude max, so no limits there...
happens to me as well. Usually after an hour or so.
I cannot clear without starting a new session.
Yes facing exact same issue on Claude max plan.
Same problem on max plan
Exiting claude and restarting seems to fix it, something in the session breaks it randomly.
+1, also getting this every few days on Max
+1 same issue on Max
!Image
Also getting this error on Max:
This happened multiple times, generally after some WebSearch/FetchContent calls. Claude-code then essentially becomes stuck, because it keeps retrying forever.
@MashoodAli-Official could you pls reopen this as it seems to persist for many users, independent of billing,.
This issue has multiple root causes, but we are working on driving down this error rate.
Just got this error! Anybody got any solution or I need to start a new conversation?
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
Same error here, appearing randomly
Same error, also appearing randomly
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.
Facing this, too. Had to start a new session, which destroyed context.
same
same here
⎿ API Error: 400
{"type":"error","error":{"type":"invalid_request_error","message":"messages.0.content.3:
unexpected
tool_use_idfound intool_resultblocks: toolu_015GWaNPsUS11miZmDUCb8Za. Eachtool_resultblock must have a correspondingtool_useblock in the previous message."}}Also having same issue. waited for some time thinking maybe had tpm limit or so, but no...
⎿ 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)"}}
⎿ 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)"}}
⎿ Set model to sonnet (claude-sonnet-4-20250514)
⎿ 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)"}}
⎿ Set model to opus (claude-opus-4-20250514)
⎿ (no content)
⎿ 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)"}}
also having the same issue ..
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)"}}
also same issue:
API Error: 400 {"type":"error","error":{"type":"invalid_request_error","message":"messages.6:
tool_useids were found withouttool_resultblocks immediately after: toolu_01JvpzaSw14Yy7vEjq1B3mH6. Eachtool_useblock must have a correspondingtool_resultblock in the next message."}}Closing this as stale (original bug report is against a pre 1.0 version) - please open a new issue for any new bugs.
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.