Skip to content

The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]

test(e2e): pin marker alias connection params staying off the routed tier

mateo-berrid4db4b1379b9
diff --git a/tests/e2e/coverage_registry/reliability.yaml b/tests/e2e/coverage_registry/reliability.yaml
index 5a1d437eac9..b50551ec105 100644
--- a/tests/e2e/coverage_registry/reliability.yaml
+++ b/tests/e2e/coverage_registry/reliability.yaml
@@ -24,6 +24,7 @@
- {id: reliability.routing.tagged_marker.untagged_tier_deployments_still_served, module: reliability, tier: P1, behavior: routing, variant: tagged_marker, assertions: [untagged_tier_deployments_still_served], exercised_on: [chat_completions, messages], source: "litellm/router_strategy/tag_based_routing.py:433", rationale: "Routing tags the marker consumed no longer constrain deployment selection inside the routed tier group, so untagged tier deployments serve the rewrite (GitHub issue #36621)"}
- {id: reliability.routing.tagged_marker.tag_semantics_stay_strict, module: reliability, tier: P1, behavior: routing, variant: tagged_marker, assertions: [tag_semantics_stay_strict], exercised_on: [chat_completions], source: "litellm/router_strategy/tag_based_routing.py:299", rationale: "Tag consumption must not loosen strict semantics: a tagged call aimed straight at an untagged deployment still gets the 401 tags-configuration denial"}
- {id: reliability.routing.tagged_marker.responses_input_routes_through_marker, module: reliability, tier: P0, behavior: routing, variant: tagged_marker, assertions: [responses_input_routes_through_marker], exercised_on: [responses], source: "litellm/router.py:11489", rationale: "Tagged /v1/responses (header or litellm_metadata.tags, string or list input) routes through the marker to its tier, extending the GitHub issues #36620/#36621 tag split to the Responses surface"}
+- {id: reliability.routing.tagged_marker.alias_connection_params_stay_with_tier, module: reliability, tier: P0, behavior: routing, variant: tagged_marker, assertions: [alias_connection_params_stay_with_tier], exercised_on: [chat_completions], source: "litellm/router.py:11567", rationale: "An api_key or api_base on the marker alias is never forwarded onto the routed request; the tier deployment calls its provider with its own credential (GitHub PR #36626)"}
- {id: reliability.routing.semantic_auto_router.responses_input_routed, module: reliability, tier: P0, behavior: routing, variant: semantic_auto_router, assertions: [responses_input_routed], exercised_on: [responses], source: "litellm/router_strategy/auto_router/auto_router.py:131", fail_before_fix: proven, rationale: "/v1/responses input is resolved into messages for the semantic auto-router pre-routing hook instead of failing 400 Unmapped LLM provider auto_router (GitHub PR #37333)"}
- {id: reliability.routing.strategy_alias.custom_pricing_ignored, module: reliability, tier: P1, behavior: routing, variant: strategy_alias, assertions: [custom_pricing_ignored], exercised_on: [chat_completions], source: "litellm/router.py:11489", rationale: "Custom pricing on a strategy-router alias never prices the routed request; spend logs at the routed tier deployment's own rate (GitHub PR #36691)"}
- {id: reliability.routing.complexity_heuristic.scores_current_ask_only, module: reliability, tier: P1, behavior: routing, variant: complexity_heuristic, assertions: [scores_current_ask_only], exercised_on: [chat_completions], source: "router_strategy/complexity_router/complexity_router.py:942", rationale: "The heuristic complexity classifier scores the caller's current ask only, so a keyword-heavy agent system prompt cannot inflate the tier (GitHub PR #36721)"}
diff --git a/tests/e2e/router/test_auto_router_regressions_e2e.py b/tests/e2e/router/test_auto_router_regressions_e2e.py
index ee68d3fa1bb..a23b50f2a73 100644
--- a/tests/e2e/router/test_auto_router_regressions_e2e.py
+++ b/tests/e2e/router/test_auto_router_regressions_e2e.py
@@ -26,6 +26,9 @@ pins one fixed behavior:
request; spend logs at the routed tier deployment's own rate.
- GitHub PR #36721: the heuristic complexity classifier scores the caller's
current ask only, so a large agent system prompt cannot inflate the tier.
+- GitHub PR #36626: connection params on the marker alias (``api_key``,
+ ``api_base``) stay with the alias; the routed tier calls its provider with
+ its own credentials.
Every deployment is registered via /model/new (stage has no static config for
these) and ``enable_tag_filtering`` is flipped through /config/update and
@@ -171,6 +174,12 @@ class SemanticAutoRouter:
embedding: str
+@dataclass(frozen=True, slots=True)
+class CredentialedAlias:
+ alias: str
+ tier: str
+
+
def _provider_key(env_var: str) -> str:
return os.environ.get(env_var) or f"os.environ/{env_var}"
@@ -382,6 +391,27 @@ def semantic_auto_router(proxy: ProxyClient) -> Iterator[SemanticAutoRouter]:
proxy.delete_model(model_id)
[email protected](scope="module")
+def credentialed_alias(proxy: ProxyClient) -> Iterator[CredentialedAlias]:
+ marker: Final = unique_marker()
+ named: Final = CredentialedAlias(alias=f"e2e-cred-alias-{marker}", tier=f"e2e-cred-tier-{marker}")
+ alias_params: Final = LiteLLMParamsBody(
+ model="auto_router/complexity_router",
+ complexity_router_config=_uniform_tier_config(named.tier),
+ api_key=f"sk-alias-never-used-{marker}",
+ )
+ registrations: Final[tuple[tuple[str, LiteLLMParamsBody], ...]] = (
+ (named.tier, LiteLLMParamsBody(model=CHEAP_MODEL, api_key=_provider_key("ANTHROPIC_API_KEY"))),
+ (named.alias, alias_params),
+ )
+ created: Final = tuple(proxy.create_model(name, params) for name, params in registrations)
+ try:
+ yield named
+ finally:
+ for model_id in created:
+ proxy.delete_model(model_id)
+
+
class TestTagSplitRouting:
@pytest.mark.covers("reliability.routing.tagged_marker.request_tag_selects_marker")
def test_body_tagged_chat_routes_through_the_marker_to_its_tier(
@@ -630,3 +660,20 @@ class TestSemanticAutoRouterResponses:
_assert_served_only_by(
rows, CHEAP_SERVED | {semantic_auto_router.target}, "semantic auto-router /v1/responses string input"
)
+
+
+class TestAliasParamForwarding:
+ @pytest.mark.covers("reliability.routing.tagged_marker.alias_connection_params_stay_with_tier")
+ def test_alias_api_key_never_overrides_the_tier_credential(
+ self, proxy: ProxyClient, resources: ResourceManager, credentialed_alias: CredentialedAlias
+ ) -> None:
+ """Pins GitHub PR #36626: an api_key set on the marker alias entry is
+ never forwarded onto the routed request, so the tier deployment calls
+ its provider with its own credential. Before the fix the alias's key
+ was copied into the request, overriding the tier's credential, and
+ every routed call failed provider auth."""
+ key: Final = _key_for(proxy, resources, [credentialed_alias.alias, credentialed_alias.tier])
+ chat: Final = unwrap(proxy.chat(key, _hello_chat_body(credentialed_alias.alias)))
+ assert chat.choices, "chat through the credentialed alias returned no choices"
+ rows: Final = proxy.poll_logs_for_key(key, min_rows=1)
+ _assert_served_only_by(rows, CHEAP_SERVED | {credentialed_alias.tier}, "chat through the credentialed alias")