anthropics / anthropics/claude-code

[BUG] Subscription auth (Pro/Max) ignores ANTHROPIC_BASE_URL — requests never reach custom proxy (LiteLLM)

Aperta
#91,746 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub
area:api area:auth area:networking bug platform:windows
Lingua principale
Python
Stelle
145k
Fork
23.1k
Metriche di merge delle PR
Metriche PR in attesa

Descrizione

### Preflight Checklist

- [x] I have searched [existing issues](https://github.com/anthropics/claude-code/issues?q=is%3Aissue%20state%3Aopen%20label%3Abug) and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code

### What's Wrong?

Claude Code should route all requests through the configured ANTHROPIC_BASE_URL,
regardless of auth method — the same way it does when using an API key. With
subscription-based auth (Pro/Max), it should still respect this setting and send
requests to the custom proxy (LiteLLM in our case) instead of bypassing it entirely.

### What Should Happen?

Claude Code should route all requests through the configured ANTHROPIC_BASE_URL,
regardless of auth method. With subscription-based auth (Pro/Max), it should still
respect this setting and send requests to the custom proxy (LiteLLM in our case)
instead of bypassing it entirely.

### Error Messages/Logs

```shell
No error is thrown — Claude Code runs normally with no visible failure.
The issue is that no requests appear in LiteLLM's logs at all, confirming
Claude Code is not sending traffic to the configured ANTHROPIC_BASE_URL.

LiteLLM logs confirm the proxy itself is up and working correctly when
tested directly (e.g., via curl) — it simply never receives anything from
Claude Code.
```

### Steps to Reproduce

1. Set up a LiteLLM proxy locally/remotely and confirm it's running and reachable
(e.g., via a direct curl request to the proxy endpoint).

2. Configure Claude Code's `settings.json` with:
ANTHROPIC_BASE_URL=

3. Ensure Claude Code is authenticated via subscription (Pro/Max) — not an API key.

4. Run any normal Claude Code command/session (e.g., `claude "explain this file"`).

5. Check LiteLLM's logs.

Expected: The request should appear in LiteLLM's logs, since ANTHROPIC_BASE_URL
is configured to route traffic through it.

Actual: No request ever appears in LiteLLM's logs. Claude Code completes the
session normally, but traffic never reaches the proxy — as if ANTHROPIC_BASE_URL
is being ignored entirely when using subscription-based auth.

Note: We confirmed LiteLLM itself works correctly — testing it directly with
curl shows it responding as expected. The issue is isolated to Claude Code not
sending requests to it in the first place.

### Claude Model

Sonnet (default)

### Is this a regression?

I don't know

### Last Working Version

_No response_

### Claude Code Version

2.1.246

### Platform

Anthropic API

### Operating System

Windows

### Terminal/Shell

VS Code integrated terminal

### Additional Information

Relevant settings.json config (secrets redacted):

model_list:
- model_name: claude
litellm_params:
model: anthropic/claude-sonnet-4-5-20250929

general_settings:
forward_client_headers_to_llm_api: true

litellm_settings:
master_key: "sk-***REDACTED***"

LiteLLM proxy logs confirm it is running and reachable — a direct curl request
to the proxy returns a valid response. However, no request from Claude Code
ever appears in these logs during an active Claude Code session, even though
Claude Code itself functions normally (responds, completes tasks, etc.) —
suggesting it's silently falling back to the default Anthropic endpoint
instead of respecting ANTHROPIC_BASE_URL.

We suspect Claude Code may only respect ANTHROPIC_BASE_URL when using
API-key-based auth, and silently ignores it under subscription-based
(Pro/Max) auth — but we couldn't find this documented anywhere, hence
this report.

Happy to share more of our LiteLLM config or logs if useful for debugging.

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Direzione di ricerca

Start by tracing how settings.json supplies ANTHROPIC_BASE_URL and how subscription-based authentication selects the request endpoint. Reproduce with the LiteLLM proxy, verify the direct curl request and LiteLLM logs, then run a normal Claude Code session; done means the session's request appears in the proxy logs for Pro/Max authentication.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Valutazione

Stack tecnologico
python
Ambito
api, authentication
Tipo di issue
Bug
Difficoltà
4/5
Tempo stimato
3-5 giorni
Stato di attività
Attiva
Chiarezza
Abbastanza chiara
Idoneità per principianti
55/100

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.