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

Expose timeout settings

Open mrh-chain opened this issue 6 months ago • 4 comments

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.

mrh-chain avatar Jun 12 '25 11:06 mrh-chain

the problem is "env": { "MAX_THINKING_TOKENS": "32000" } , remove it

furkancak1r avatar Jun 19 '25 07:06 furkancak1r

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.

drdrewAQ avatar Jun 23 '25 18:06 drdrewAQ

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!

lhjt avatar Jun 24 '25 02:06 lhjt

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

lhjt avatar Jun 24 '25 03:06 lhjt

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

junmediatek avatar Jul 07 '25 00:07 junmediatek

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

I didn't. I manually grepped through the sdk linked to the CLI (the minified bundle).

lhjt avatar Jul 07 '25 01:07 lhjt

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

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 avatar Jul 07 '25 01:07 junmediatek

@junmediatek you can grep the <claude_install_dir>/lib/node_modules/@anthropic-ai/claude-code/cli.js file for API_TIMEOUT_MS

lhjt avatar Jul 09 '25 05:07 lhjt

@lhjt Thanks, I got it

junmediatek avatar Jul 09 '25 22:07 junmediatek

@junmediatek you can grep the <claude_install_dir>/lib/node_modules/@anthropic-ai/claude-code/cli.js file for API_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 😆

usersina avatar Jul 17 '25 08:07 usersina

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.

skye0402 avatar Aug 02 '25 11:08 skye0402

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.

github-actions[bot] avatar Dec 03 '25 10:12 github-actions[bot]