[BUG] API Error: 400 Input is too long for requested model.
Status Fixed / completed
Maintainer reply ✓ Yes — bcherny
Workaround ✓ Mentioned in thread ↓
Activity 14 comments · opened Apr 10, 2025 · closed Jun 10, 2025
💡 Likely answer: A maintainer (bcherny, collaborator)
responded on this thread — see the highlighted reply below.
Environment
- Platform (select one):
- [ ] Anthropic API
- [x] AWS Bedrock
- [ ] Google Vertex AI
- [ ] Other: <!-- specify -->
- Claude CLI version: 0.2.67
- Operating System: macOs 15.3.2
- Terminal: Warp
Bug Description
<img width="1153" alt="Image" src="https://github.com/user-attachments/assets/91410083-9a0f-40a4-b6e7-5b5bea3ea5e9" />
Getting this error after an attempt of reading the large file, /compact does not help. Have to exit and open claude code again
Steps to Reproduce
- Get context to fill up to about 70%
- Make claude read file of about 100k+ tokens
- See the error, API Error: 400 Input is too long for requested model.
- try to compact, see the error Error: Error during compaction: Error: API Error: 400 Input is too long for requested model.
Expected Behavior
Compact should work regardless of volume of used context
Actual Behavior
All subsequent promts returns an error API Error: 400 Input is too long for requested model.
Additional Context
<!-- Add any other context about the problem here, such as screenshots, logs, etc. -->
14 Comments
As a workaround:
Thanks @bcherny I'll try that if issue pops up again.
Thanks @bcherny - unfortunately the workaround doesn't work for me, as the error appears when Claude is handing my initial message. Here is a sample:
Any tips for getting this to work, short of breaking these large files apart? Thanks!
+1 on this error.
This causes early exit when in headless mode. I'm imagining context window overflow is covered for Anthropic first party API. Would be nice to have recovery behavior for Bedrock.
having this issue with regular base claude code!
We've made a bunch of improvements to context management recently, and this should feel a lot better. Feel free to reopen if you're still seeing issues.
I just got this today with 60% context use. Just in case anyone is interested in still trying to address this. I switched to Bedrock today and had never encountered this before today.
@sid374 do you want me to open a new bug?
Still seeing this as well with bedrock with
--continuesame here - bedrock suffers from this issue
Also seeing this still with Bedrock Claude 4 Sonnet
Got a fix - just got to the prompt that caused the 400, double click which makes it editable, edit and send.
in my case i asked cline to read a file which caused 400, i edited to not read that . it did not try to read in the next run and was able to chat again. no need to compact the context.
I'm still facing the same issue but do not have permissions to reopen this ticket cc: @sid374
The same prompt when inside claude is working fine but when using
claude -p $PROMPT(or pipe), I'm getting the following errorHaving the same issue, using Bedrock. In my case, once Claude Code throws it will continue to throw the error for any prompt of any length until I exit and restart. Happens 100% of the time on specific calls no matter the context size Claude Code is dealing with.
I did some logging and got a hot take from Claude Code. Seems that Claude Code can't recover when a (obviously) too large context is sent:
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.