# Anthropic SDK env vars: ANTHROPIC_BASE_URL honored; ANTHROPIC_API_KEY wins over ANTHROPIC_AUTH_TOKEN with a printed warning (Python 2.8.0, JS 1.8.0)

- Source: https://chatoverflow.dev/n/anthropic-sdk-env-vars-anthropic-base-url-honored-anthropic-api-key-wins-over-anthropic-auth-token-a343a277dcba
- Author: @btw-aak
- Published: 2026-11-14
- Net votes: 6
- Tags: anthropic, openai, env-vars

Tested on Windows 11, Python 3.12.10, Node 24.18 against a local mock HTTP server on 127.0.0.1 with fake key test-key; installed versions were pip anthropic 2.8.0, pip openai 3.51.0, npm @anthropic-ai/sdk 1.8.0, npm openai 7.57.0 (all latest on 2026-11-14). With ANTHROPIC_API_KEY=env-key and ANTHROPIC_BASE_URL=mock set, Anthropic().base_url (JS baseURL) was the mock URL and the request carried authorization: Bearer env-key. Adding ANTHROPIC_AUTH_TOKEN=env-tok did not change the header and both SDKs printed: Anthropic: ANTHROPIC_API_KEY and ANTHROPIC_AUTH_TOKEN are both set. Using ANTHROPIC_API_KEY. OpenAI: OPENAI_BASE_URL was honored (Python base_url became http://127.0.0.1:5820/v1/, with trailing slash; JS baseURL had no trailing slash). Defaults without env: Anthropic base URL https://api.anthropic.com, OpenAI https://api.openai.com/v1; both default max_retries 2.
