Expose timeout settings
In the latest release of Claude Code I have begun seeing a lot of API Error (Request timed out)... errors.
The setup I'm using is an LLM Gateway (LiteLLM) in front of AWS Bedrock - if I connect directly to Bedrock, I don't have this issue.
I expect my requests to take a bit longer given they are going through an LLM Gateway, so it would be great if the setting that decides what the threshold is for a timeout would be configurable!
I've previously have issues with the Sonnet 4 model being ratelimited in Bedrock, but unless newer versions of Claude Code has changed the error message, I don't think this is it.
the problem is "env": { "MAX_THINKING_TOKENS": "32000" } , remove it
Same issue as OP, timeout errors when using bedrock behind LiteLLM proxy. I'm using Claude 3.7, and I also don't have timeout issues going straight to bedrock either. I have disabled caching, and disabled nonessential traffic as well.
I am also in a similar position where I have an LLM gateway/proxy through which all of Claude Code's requests go through (except vertex in my case).
If we could have an option to configure the API request timeout (similar to the MCP timeout), I think that would be great as I can see the requests completing after ~120s in my LLM gateway (even though claude code has already timed out).
Happy to provide any other details. Thanks!
For anyone else on this thread or who comes across this - I did some investigating and it appears there is an environment variable you can configure for this: API_TIMEOUT_MS
This fixed the issue for me at least with the API Error (Request timed out.) issues disappearing and the CC continuing successfully. This primarily affects calls that use the rawPredict rather than streamingRawPredict calls (not sure why there are cases where rawPredict is used over streamingRawPredict in case anyone can shed some light on that).
hi @lhjt Where did you see API_TIMEOUT_MS in the documentation or website?
For anyone else on this thread or who comes across this - I did some investigating and it appears there is an environment variable you can configure for this:
API_TIMEOUT_MSThis fixed the issue for me at least with the
API Error (Request timed out.)issues disappearing and the CC continuing successfully. This primarily affects calls that use therawPredictrather thanstreamingRawPredictcalls (not sure why there are cases whererawPredictis used overstreamingRawPredictin case anyone can shed some light on that).
hi @lhjt Where did you see API_TIMEOUT_MS in the documentation or website?
For anyone else on this thread or who comes across this - I did some investigating and it appears there is an environment variable you can configure for this:
API_TIMEOUT_MSThis fixed the issue for me at least with the
API Error (Request timed out.)issues disappearing and the CC continuing successfully. This primarily affects calls that use therawPredictrather thanstreamingRawPredictcalls (not sure why there are cases whererawPredictis used overstreamingRawPredictin case anyone can shed some light on that).
I didn't. I manually grepped through the sdk linked to the CLI (the minified bundle).
hi @lhjt Where did you see API_TIMEOUT_MS in the documentation or website?
For anyone else on this thread or who comes across this - I did some investigating and it appears there is an environment variable you can configure for this:
API_TIMEOUT_MSThis fixed the issue for me at least with theAPI Error (Request timed out.)issues disappearing and the CC continuing successfully. This primarily affects calls that use therawPredictrather thanstreamingRawPredictcalls (not sure why there are cases whererawPredictis used overstreamingRawPredictin case anyone can shed some light on that).I didn't. I manually grepped through the sdk linked to the CLI (the minified bundle).
Hi @lhjt which sdk did you grepped?Could you show me the link?
@junmediatek you can grep the <claude_install_dir>/lib/node_modules/@anthropic-ai/claude-code/cli.js file for API_TIMEOUT_MS
@lhjt Thanks, I got it
@junmediatek you can grep the
<claude_install_dir>/lib/node_modules/@anthropic-ai/claude-code/cli.jsfile forAPI_TIMEOUT_MS
I'd prefer to see this as an environment variable, here's what I'm seeing lately (using Amazon Bedrock directly)...
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 1 seconds… (attempt 1/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 1 seconds… (attempt 2/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 2 seconds… (attempt 3/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 5 seconds… (attempt 4/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 1 seconds… (attempt 1/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 1 seconds… (attempt 2/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 2 seconds… (attempt 3/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 5 seconds… (attempt 4/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 1 seconds… (attempt 1/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 1 seconds… (attempt 2/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 2 seconds… (attempt 3/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 5 seconds… (attempt 4/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 1 seconds… (attempt 1/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 1 seconds… (attempt 2/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 2 seconds… (attempt 3/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 5 seconds… (attempt 4/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 1 seconds… (attempt 1/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 1 seconds… (attempt 2/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 2 seconds… (attempt 3/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 1 seconds… (attempt 1/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 1 seconds… (attempt 2/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 2 seconds… (attempt 3/10)
⎿ API Error (429 Too many requests, please wait before trying again.) · Retrying in 4 seconds… (attempt 4/10)
● Task(Search for drawing components)
⎿ Done (10 tool uses · 44.8k tokens · 2m 21.7s)
I mean, it does work in the end. But I'd rather increase the timeout myself than getting yelled at 😆
same issue here. #4968 - opus is worst but also sonnet shows this. Also litellm proxy. The responses are delivered but not in time. Allow us to extend the timeout as the parameter API_TIMEOUT_MS has no effect.
This issue has been inactive for 30 days. If the issue is still occurring, please comment to let us know. Otherwise, this issue will be automatically closed in 30 days for housekeeping purposes.