From f4f785e0bb87904dc0f02a585f353ba5c463c7d1 Mon Sep 17 00:00:00 2001 From: William Turner Date: Sun, 23 Aug 2026 16:08:26 +0000 Subject: [PATCH] =?UTF-8?q?Re-add=20the=20claude-subscription=20LiteLLM=20?= =?UTF-8?q?route=20=E2=80=94=20confirmed=20working=20for=20the=20real=20CL?= =?UTF-8?q?I?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Earlier this session I removed this route after a curl-based test got rejected by Anthropic and concluded OAuth subscription forwarding doesn't work through a proxy at all. That conclusion was wrong: the real `claude` CLI binary, with ANTHROPIC_BASE_URL pointed at litellm, successfully completed a request billed against the subscription. The earlier curl test just didn't replicate whatever header/fingerprint Anthropic requires from genuine Claude Code CLI traffic — LiteLLM relays that fine when the real CLI is the caller, but a hand-built request from any other client (Hermes included) still gets rejected the same way curl did. --- litellm-config.yaml | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/litellm-config.yaml b/litellm-config.yaml index 7485056..94692ed 100644 --- a/litellm-config.yaml +++ b/litellm-config.yaml @@ -11,13 +11,19 @@ model_list: model: openrouter/openai/gpt-4o-mini api_key: os.environ/OPENROUTER_API_KEY - # NOT included: a "claude-subscription" route forwarding the Claude Pro/Max OAuth token - # (from `claude setup-token`) through to Anthropic's raw API. Tested and confirmed - # non-functional — Anthropic returns a generic rate_limit_error for ANY direct API call - # using this token type outside the real Claude Code CLI client (reproduced with plain - # curl straight to api.anthropic.com, bypassing LiteLLM entirely, same result). The - # subscription token only works through the actual Claude Code CLI, which is what - # claude-agent already uses directly for code tasks — it was never routed through here. + # Routes to Anthropic using the CALLER's forwarded Authorization header (the Claude + # Pro/Max subscription OAuth token) instead of a LiteLLM-held API key — billed against + # the subscription, not per-token. CONFIRMED WORKING, but only for the real `claude` + # CLI binary as caller (tested: `claude -p` with ANTHROPIC_BASE_URL pointed here + # returned a real completion). An earlier test with plain curl replicating the same + # request shape failed — Anthropic apparently requires header/fingerprint details only + # the real CLI sends, which LiteLLM faithfully relays but a hand-built request won't + # have. Do NOT expect this to work for other callers (Hermes, generic HTTP clients) — + # they aren't the real CLI and can't reproduce that fingerprint. + - model_name: anthropic-claude + litellm_params: + model: anthropic/claude-sonnet-5 general_settings: + forward_client_headers_to_llm_api: true master_key: os.environ/LITELLM_MASTER_KEY -- 2.54.0