Expose timeout settings

Status Closed — not planned
Maintainer reply None cached
Activity 14 comments · opened Jun 12, 2025 · closed Jan 3, 2026

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.

View original on GitHub ↗

14 Comments

furkancak1r · 1 year ago

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

drdrewAQ · 1 year ago

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.

lhjt · 1 year ago

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

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

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

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

lhjt · 1 year ago

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

junmediatek · 1 year ago

@lhjt
Thanks, I got it

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

skye0402 · 1 year ago

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.

github-actions[bot] · 9 months ago

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] · 7 months ago

This issue has been automatically closed due to 60 days of inactivity. If you're still experiencing this issue, please open a new issue with updated information.

github-actions[bot] · 7 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.