Answer: In your shell, set the variable before launching `claude` (e.g., `export API_TIMEOUT_MS="1200000"` on macOS/Linux/WSL, `$env:API_TIMEOUT_MS = "1200000"` in PowerShell, or `set API_TIMEOUT_MS=1200000` in CMD); to persist it, add the export line to your shell profile or use `setx`/`[Environment]::SetEnvironmentVariable`. In a settings file, add variables under the `env` key in a `settings.json` file, creating the file if it doesn't exist. Status: Confirmed Entry: tool/claude-code/settings/set-environment-variables Revision: 2 Digest: sha256:2029d3650f485599 (changes whenever the content changes) Timeline: Created: 2026-11-13T03:04:05Z Last changed: 2026-11-16T12:08:45Z (settings file example: — → ~/.claude/settings.json) Last verified: 2026-11-20T12:20:30Z Next check: 2026-11-21T12:20:30Z Check interval: Daily Expected change: No fixed schedule Data: Field | Value | Source | As of shell example (macOS/Linux/WSL) | export API_TIMEOUT_MS="1200000" | [1] | 2026-11-20 PowerShell example | $env:API_TIMEOUT_MS = "1200000" | [1] | 2026-11-20 CMD example | set API_TIMEOUT_MS=1200000 | [1] | 2026-11-20 settings file key | env | [1] | 2026-11-20 settings file example | ~/.claude/settings.json | [1] | 2026-11-20 Sources: [1] Anthropic. "Environment variables". https://code.claude.com/docs/en/env-vars.md Role: primary. Accessed: 2026-11-20T12:20:30Z Quote: "export API_TIMEOUT_MS="1200000"" (Supports: shell example (macOS/Linux/WSL)) Quote: "$env:API_TIMEOUT_MS = "1200000"" (Supports: PowerShell example) Quote: "set API_TIMEOUT_MS=1200000" (Supports: CMD example) Quote: "Add variables under the `env` key in a `settings.json` file, creating the file if it doesn't exist." (Supports: settings file key) Quote: "```json ~/.claude/settings.json theme={null}" (Supports: settings file example) Published: 2026-11-20T02:53:00Z Snapshot SHA-256: 5a92055baebcd045c25b5e47ef862490e0db33a9505309b81cadf159ce951572 (captured 2026-11-20T12:20:30Z) Verification: Method: Automated extraction from [1] with deepseek-flash (JSON output, thinking disabled). Every value was checked by code to appear verbatim in a quoted passage of [1]. Cross-check: not-available at 2026-11-20T12:20:30Z. No independent second source is configured for this entry Last successful check: 2026-11-20T12:20:30Z Last attempt: 2026-11-20T12:20:30Z Notes and limitations: Extracted automatically from a single official source (section "Set environment variables"). Related: https://latestn.com/tool/claude-code/settings/set-environment-variables-sdk How do I set environment variables for a Claude Code Agent SDK session? https://latestn.com/tool/claude-code/settings/set-up-status-line How do I set up a custom status line in Claude Code? https://latestn.com/tool/claude-code/settings/set-working-directory-sdk How do I change the working directory for a Claude Code Agent SDK session? https://latestn.com/tool/claude-code/settings/self-hosted-env-var-only-settings Which settings for Claude Code self-hosted environments can only be configured via environment variables? https://latestn.com/tool/claude-code/settings/session-identity-env-vars Which environment variables are related to Claude Code self-hosted session identity verification? https://latestn.com/tool/claude-code/settings/set-cloud-environment-variables How do I set environment variables for a Claude Code cloud environment? https://latestn.com/tool/ All entries in AI tools Change log: Time | Event | Change | Source 2026-11-16T12:08:45Z | changed | settings file example: — → ~/.claude/settings.json | [1] 2026-11-16T12:08:45Z | changed | settings file key: — → env | [1] 2026-11-16T12:08:45Z | changed | shell example (macOS/Linux/WSL): — → export API_TIMEOUT_MS="1200000" | [1] 2026-11-16T12:08:45Z | changed | Settings file example: ~/.claude/settings.json → — | [1] 2026-11-16T12:08:45Z | changed | Settings file key: env → — | [1] 2026-11-16T12:08:45Z | changed | Shell example (macOS, Linux, WSL): export API_TIMEOUT_MS="1200000" → — | [1] 2026-11-13T03:04:05Z | added | Entry created | — Changes for this entry as a feed: https://latestn.com/tool/claude-code/settings/set-environment-variables/latest Challenge this entry: Open challenges: None How: If a value here is wrong or out of date, send what is wrong and a link to evidence. Challenges are queued and checked against the evidence; they do not change the entry by themselves. If the entry changes as a result, the change log says so. Form: https://latestn.com/dispute/tool/claude-code/settings/set-environment-variables POST: https://latestn.com/dispute/tool/claude-code/settings/set-environment-variables with claim, evidence_url, and optionally field and contact (form-encoded or JSON) GET: https://latestn.com/dispute/tool/claude-code/settings/set-environment-variables?claim={what is wrong}&evidence_url={link} How to cite: LatestN. (2026). How do I set environment variables for Claude Code in my shell or in a settings file? Revision 2, last verified 2026-11-20T12:20:30Z. https://latestn.com/tool/claude-code/settings/set-environment-variables (accessed 2026-11-21T09:53:27Z). @misc{LatestN_tool_claude_code_settings_set_environment_variables_r2, title = {How do I set environment variables for Claude Code in my shell or in a settings file?}, author = {{LatestN}}, year = {2026}, howpublished = {\url{https://latestn.com/tool/claude-code/settings/set-environment-variables}}, note = {Revision 2; digest sha256:2029d3650f485599; last verified 2026-11-20T12:20:30Z; accessed 2026-11-21T09:53:27Z} } Reuse: License: CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/) Attribution: Copying and adapting are allowed, including commercially, if you credit LatestN and link to the entry you used. Each entry ends with a ready-made citation. URL: https://latestn.com/tool/claude-code/settings/set-environment-variables