Bitropy patches on v1.82.3-stable: passthrough credential priority + header security#2
Open
pkieszcz wants to merge 2 commits intov1.82.3-stable-basefrom
Open
Bitropy patches on v1.82.3-stable: passthrough credential priority + header security#2pkieszcz wants to merge 2 commits intov1.82.3-stable-basefrom
pkieszcz wants to merge 2 commits intov1.82.3-stable-basefrom
Conversation
…ream providers Prevent x-litellm-api-key (LiteLLM's virtual key) from being leaked to upstream providers when _forward_headers=True is used in passthrough endpoints.
Client-provided credentials now take precedence over server credentials in the /anthropic/ passthrough endpoint. This enables mixed mode where: 1. Client sends x-api-key → forwarded as-is (user pays via own API key) 2. Client sends Authorization → forwarded as-is (user pays via OAuth/Max) 3. No client credentials + server ANTHROPIC_API_KEY → server key used 4. No client credentials + no server key → no credentials forwarded Previously the server always sent x-api-key (even literal "None" when unconfigured), overwriting any client-provided credentials and breaking Claude Code Max (OAuth) and BYOK scenarios. Supersedes the simpler one-liner from d742c76 on v1.81.12-stable-patched. Based on the approach from PR BerriAI#20429 (closed) and reverted PR BerriAI#14821.
tdi
approved these changes
Mar 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What this is
2 patches on top of upstream
v1.82.3-stablethat fix the Anthropic passthrough endpoint for Claude Code Max (OAuth) and BYOK scenarios.Full documentation:
PASSTHROUGH_PATCHES.mdPatches
1. Strip x-litellm-api-key from forwarded headers (security)
File:
litellm/passthrough/utils.py(+1 line)Without this, the
x-litellm-api-keyproxy auth header is forwarded to Anthropic, leaking credentials.Upstream PR: BerriAI#20432 (open, unreviewed since Feb 2026)
2. Credential priority for Anthropic passthrough (critical)
File:
litellm/proxy/pass_through_endpoints/llm_passthrough_endpoints.py(+19/-6 lines)The upstream code always sends
x-api-key: "{}".format(anthropic_api_key)as a custom header, which:x-api-key: Nonewhen no serverANTHROPIC_API_KEYis setNew behavior (credential priority):
Background
/anthropic/route has auth included — no premium license or custompass_through_endpointsconfig neededTesting
Tested locally on v1.82.4 (main-stable) with header inspection (request catcher) and real Anthropic API:
Deploy
Claude Code config
{ "env": { "ANTHROPIC_BASE_URL": "https://ai.demo.internal.bitropy.io/anthropic", "ANTHROPIC_CUSTOM_HEADERS": "x-litellm-api-key: sk-<your-virtual-key>" } }🤖 Generated with Claude Code