Skip to content

fix(router): keep one caller's own bad credential from cooling down a shared deployment - #53431

Merged
ryan-crabbe-berri merged 9 commits into
mainfrom
litellm_clientside_cred_cooldown_scope
Nov 22, 2026
Merged

ryan-crabbe-berri merged 9 commits into
mainfrom
litellm_clientside_cred_cooldown_scope

Conversation

@ryan-crabbe-berri

@ryan-crabbe-berri ryan-crabbe-berri commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

Handwritten 1-3 sentence description

[insert handwritten description here]

Details

TLDR

Problem this solves:

  • One caller sends their own bad login detail for a shared model
  • The proxy then switches that shared model off for every other caller
  • Everyone else gets "no deployments available" for a minute, and one caller can keep it down

How it solves it:

  • If the failure came from what that one caller sent, only that caller sees it
  • The shared model stays on for everyone else, including fallback targets
  • A caller's own AWS keys count for any failure, since they hit the caller's own AWS account
  • A caller's Azure token or OpenAI org only count when the provider rejects the login
  • A caller's Vertex credentials count for a rejected login or a "not found", since they can pick the project
  • Version, region and location fields only count for the "not found" error a wrong value gives
  • If the admin's own key is broken, the model still switches off exactly like today

User Flow

Before: one app sends a bad credential of its own, and every other app on the same model is locked out for 60 seconds

  1. The admin shares an Azure model shared-azure and allows callers to send their own credentials (allow_client_side_credentials: true)
  2. App A sends POST https://litellm-domain/v1/chat/completions with "azure_ad_token": "not-a-real-token" and gets 401
  3. App B sends a normal request for shared-azure and gets 429 "No deployments available ... All deployments for selected model are in cooldown"
  4. The same happens with no opt-in at all when App A sends "organization": "org-bogus" to an OpenAI model or "api_version": "1999-01-01" to Azure

After: App A still gets its own error, and App B keeps getting answers

  1. Same admin setup
  2. App A sends the same request and still gets 401 (or 404 for the bad api_version)
  3. App B sends a normal request for shared-azure and gets 200
  4. If the admin's own key is revoked, App B gets 429 cooldown exactly like before, even when App B's SDK sends its own ?api-version=

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have added meaningful tests
  • The handful of test files covering my change pass locally, e.g. uv run pytest tests/unit/<your_test_file>.py -v. Leave the suites (make test-unit-*, make test-unit) to CI: it finishes in ~15 minutes where a laptop takes an hour or more
  • My PR passes all required CI/CD checks (e.g., lint, schema.d.ts sync check, etc.)
  • My PR's scope is as isolated as possible; it only solves 1 specific problem
  • Every automated review on my PR's latest commit has finished, and I have addressed or replied to each of its findings before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

Screenshots / Proof of Fix

Before runs at the merge base edf8d5c57ea. After runs at 05b6c8756bd. The tip af425b4d98a only adds a 404 to the statuses caller Vertex credentials can be blamed for, which no live scenario below sends, and its unit case fails without it and passes with it. Real Azure OpenAI, OpenAI, Vertex AI and Bedrock calls through a live proxy with two workers and one dedicated Redis.

Each scenario gets its own model group so cooldowns never leak between scenarios. For each one, a plain caller calls first, then the caller with their own field, then two more plain callers (and two plain callers on the fallback target where there is one). "Guard" scenarios use a deployment whose own key is revoked, and must cool down the same way before and after.

The Bedrock legs run with PR #53362 applied on top of both commits, since that PR is what turns a caller's missing AWS profile into a 401 (on main it is a 500 that never cools down, and a bad caller AWS key answers 403, which never cools down either).

Shared setup: Redis, proxy command, env var names
redis-server --port 46391 --daemonize yes --save "" --appendonly no
# env: OPENAI_API_KEY, AZURE_API_KEY, AZURE_API_BASE, LITELLM_MASTER_KEY (fresh random), GOOGLE_APPLICATION_CREDENTIALS (Vertex ADC), AWS SSO profile <your-aws-sso-profile>
RUST_MIN_STACK=16777216 python litellm/proxy/proxy_cli.py --config config.yaml --port 46301 --num_workers 2 --detailed_debug --use_v2_migration_resolver

--reload is dropped because each leg runs from a clean git archive of its commit, and with --reload uvicorn serves one worker. Both Started server process lines appear in every leg's log.

scenarios.py (scenario list, shared by config and client)
"""Shared scenario list: each scenario gets its own model group so cooldowns never leak between them."""
AZURE = {"model": "azure/gpt-6.1-sol", "api_key": "os.environ/AZURE_API_KEY", "api_base": "os.environ/AZURE_API_BASE", "api_version": "2025-04-01-preview"}
OPENAI = {"model": "openai/gpt-5.4-mini", "api_key": "os.environ/OPENAI_API_KEY"}
VERTEX = {"model": "vertex_ai/gemini-3.8-flash", "vertex_project": "<your-gcp-project>", "vertex_location": "global"}
BEDROCK = {"model": "bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0", "aws_profile_name": "<your-aws-sso-profile>", "aws_region_name": "us-west-2"}
OPENAI_REVOKED = {"model": "openai/gpt-5.4-mini", "api_key": "sk-revoked-operator-key"}
AZURE_REVOKED = {**AZURE, "api_key": "revoked-operator-key"}

BAD_AZURE_TOKEN = {"azure_ad_token": "not-a-real-token"}
BAD_API_VERSION = {"api_version": "1999-01-01"}
BAD_ORG = {"organization": "org-notarealorg000000000000"}
BAD_VERTEX_LOCATION = {"vertex_location": "mars-central1"}
BAD_AWS_KEYS = {"aws_profile_name": None, "aws_access_key_id": "AKIAFAKEFAKEFAKEFAKE", "aws_secret_access_key": "nope"}

# (id, kind, params, endpoint, stream, caller fields, plain call first)
SCENARIOS = [
    ("azure-ad-token-chat", "regression", AZURE, "chat", False, BAD_AZURE_TOKEN, True),
    ("azure-ad-token-chat-stream", "regression", AZURE, "chat", True, BAD_AZURE_TOKEN, True),
    ("azure-ad-token-messages", "regression", AZURE, "messages", False, BAD_AZURE_TOKEN, True),
    ("azure-ad-token-responses", "regression", AZURE, "responses", False, BAD_AZURE_TOKEN, True),
    ("azure-api-version-chat", "regression", AZURE, "chat", False, BAD_API_VERSION, True),
    ("openai-organization-chat", "regression", OPENAI, "chat", False, BAD_ORG, True),
    ("openai-organization-chat-stream", "regression", OPENAI, "chat", True, BAD_ORG, True),
    ("openai-organization-messages", "regression", OPENAI, "messages", False, BAD_ORG, True),
    ("openai-organization-responses", "regression", OPENAI, "responses", False, BAD_ORG, True),
    ("vertex-location-chat", "regression", VERTEX, "chat", False, BAD_VERTEX_LOCATION, True),
    ("vertex-location-messages", "regression", VERTEX, "messages", False, BAD_VERTEX_LOCATION, True),
    ("bedrock-static-keys-chat", "unchanged", BEDROCK, "chat", False, BAD_AWS_KEYS, True),
    ("fallback-openai-organization", "regression", OPENAI, "chat", False, BAD_ORG, True),
    ("fallback-azure-ad-token", "regression", AZURE, "chat", False, BAD_AZURE_TOKEN, True),
    ("guard-operator-key-revoked", "guard", OPENAI_REVOKED, "chat", False, {}, False),
    ("guard-ignored-field-on-openai", "guard", OPENAI_REVOKED, "chat", False, {"aws_region_name": "us-east-1"}, False),
    ("guard-echoed-api-version", "guard", AZURE_REVOKED, "chat", False, {"api_version": "2025-04-01-preview"}, False),
    ("guard-sdk-api-version-query-revoked-key", "guard", AZURE_REVOKED, "chat", False, {"__query__": "api-version=2024-10-21"}, False),
    ("guard-body-api-version-revoked-key", "guard", AZURE_REVOKED, "chat", False, {"api_version": "2024-10-21"}, False),
]
FALLBACKS = {"fallback-openai-organization": OPENAI, "fallback-azure-ad-token": AZURE}

BEDROCK_MISSING_PROFILE = {**BEDROCK, "aws_profile_name": "no-such-operator-profile"}
BEDROCK_SCENARIOS = [
    ("bedrock-caller-profile-chat", "regression", BEDROCK, "chat", False, {"aws_profile_name": "no-such-profile"}, True),
    ("bedrock-caller-profile-chat-stream", "regression", BEDROCK, "chat", True, {"aws_profile_name": "no-such-profile"}, True),
    ("bedrock-caller-profile-messages", "regression", BEDROCK, "messages", False, {"aws_profile_name": "no-such-profile"}, True),
    ("bedrock-caller-profile-responses", "regression", BEDROCK, "responses", False, {"aws_profile_name": "no-such-profile"}, True),
    ("bedrock-guard-operator-profile-missing", "guard", BEDROCK_MISSING_PROFILE, "chat", False, {}, False),
    ("bedrock-guard-echoed-profile", "guard", BEDROCK_MISSING_PROFILE, "chat", False, {"aws_profile_name": "no-such-operator-profile"}, False),
]
import os as _os
if _os.environ.get("SCENARIO_SET") == "bedrock":
    SCENARIOS = BEDROCK_SCENARIOS
gen_config.py (writes config.yaml from the scenarios)
import sys
import yaml
from scenarios import SCENARIOS
import scenarios as _sc
FALLBACKS = getattr(_sc, "FALLBACKS", {}) if _sc.SCENARIOS is not getattr(_sc, "BEDROCK_SCENARIOS", None) else {}
out = sys.argv[1]
config = {
    "model_list": [{"model_name": sid, "litellm_params": dict(p), "model_info": {"id": f"{sid}-deployment"}} for sid, _k, p, *_ in SCENARIOS],
    "router_settings": {"redis_host": "127.0.0.1", "redis_port": 46391, "cooldown_time": 60, "num_retries": 0,
                        "fallbacks": [{g: [f"{g}-target"]} for g in FALLBACKS]},
    "general_settings": {"master_key": "os.environ/LITELLM_MASTER_KEY", "allow_client_side_credentials": True,
                         "coordination_redis": {"host": "127.0.0.1", "port": 46391}},
}
config["model_list"] += [{"model_name": f"{g}-target", "litellm_params": dict(p), "model_info": {"id": f"{g}-target-deployment"}} for g, p in FALLBACKS.items()]
yaml.safe_dump(config, open(out, "w"), sort_keys=False)
Generated config.yaml
model_list:
- model_name: azure-ad-token-chat
  litellm_params:
    model: azure/gpt-6.1-sol
    api_key: os.environ/AZURE_API_KEY
    api_base: os.environ/AZURE_API_BASE
    api_version: 2025-04-01-preview
  model_info:
    id: azure-ad-token-chat-deployment
- model_name: azure-ad-token-chat-stream
  litellm_params:
    model: azure/gpt-6.1-sol
    api_key: os.environ/AZURE_API_KEY
    api_base: os.environ/AZURE_API_BASE
    api_version: 2025-04-01-preview
  model_info:
    id: azure-ad-token-chat-stream-deployment
- model_name: azure-ad-token-messages
  litellm_params:
    model: azure/gpt-6.1-sol
    api_key: os.environ/AZURE_API_KEY
    api_base: os.environ/AZURE_API_BASE
    api_version: 2025-04-01-preview
  model_info:
    id: azure-ad-token-messages-deployment
- model_name: azure-ad-token-responses
  litellm_params:
    model: azure/gpt-6.1-sol
    api_key: os.environ/AZURE_API_KEY
    api_base: os.environ/AZURE_API_BASE
    api_version: 2025-04-01-preview
  model_info:
    id: azure-ad-token-responses-deployment
- model_name: azure-api-version-chat
  litellm_params:
    model: azure/gpt-6.1-sol
    api_key: os.environ/AZURE_API_KEY
    api_base: os.environ/AZURE_API_BASE
    api_version: 2025-04-01-preview
  model_info:
    id: azure-api-version-chat-deployment
- model_name: openai-organization-chat
  litellm_params:
    model: openai/gpt-5.4-mini
    api_key: os.environ/OPENAI_API_KEY
  model_info:
    id: openai-organization-chat-deployment
- model_name: openai-organization-chat-stream
  litellm_params:
    model: openai/gpt-5.4-mini
    api_key: os.environ/OPENAI_API_KEY
  model_info:
    id: openai-organization-chat-stream-deployment
- model_name: openai-organization-messages
  litellm_params:
    model: openai/gpt-5.4-mini
    api_key: os.environ/OPENAI_API_KEY
  model_info:
    id: openai-organization-messages-deployment
- model_name: openai-organization-responses
  litellm_params:
    model: openai/gpt-5.4-mini
    api_key: os.environ/OPENAI_API_KEY
  model_info:
    id: openai-organization-responses-deployment
- model_name: vertex-location-chat
  litellm_params:
    model: vertex_ai/gemini-3.8-flash
    vertex_project: <your-gcp-project>
    vertex_location: global
  model_info:
    id: vertex-location-chat-deployment
- model_name: vertex-location-messages
  litellm_params:
    model: vertex_ai/gemini-3.8-flash
    vertex_project: <your-gcp-project>
    vertex_location: global
  model_info:
    id: vertex-location-messages-deployment
- model_name: bedrock-static-keys-chat
  litellm_params:
    model: bedrock/us.anthropic.claude-haiku-4-5-20251001-v1:0
    aws_profile_name: <your-aws-sso-profile>
    aws_region_name: us-west-2
  model_info:
    id: bedrock-static-keys-chat-deployment
- model_name: fallback-openai-organization
  litellm_params:
    model: openai/gpt-5.4-mini
    api_key: os.environ/OPENAI_API_KEY
  model_info:
    id: fallback-openai-organization-deployment
- model_name: fallback-azure-ad-token
  litellm_params:
    model: azure/gpt-6.1-sol
    api_key: os.environ/AZURE_API_KEY
    api_base: os.environ/AZURE_API_BASE
    api_version: 2025-04-01-preview
  model_info:
    id: fallback-azure-ad-token-deployment
- model_name: guard-operator-key-revoked
  litellm_params:
    model: openai/gpt-5.4-mini
    api_key: sk-revoked-operator-key
  model_info:
    id: guard-operator-key-revoked-deployment
- model_name: guard-ignored-field-on-openai
  litellm_params:
    model: openai/gpt-5.4-mini
    api_key: sk-revoked-operator-key
  model_info:
    id: guard-ignored-field-on-openai-deployment
- model_name: guard-echoed-api-version
  litellm_params:
    model: azure/gpt-6.1-sol
    api_key: revoked-operator-key
    api_base: os.environ/AZURE_API_BASE
    api_version: 2025-04-01-preview
  model_info:
    id: guard-echoed-api-version-deployment
- model_name: guard-sdk-api-version-query-revoked-key
  litellm_params:
    model: azure/gpt-6.1-sol
    api_key: revoked-operator-key
    api_base: os.environ/AZURE_API_BASE
    api_version: 2025-04-01-preview
  model_info:
    id: guard-sdk-api-version-query-revoked-key-deployment
- model_name: guard-body-api-version-revoked-key
  litellm_params:
    model: azure/gpt-6.1-sol
    api_key: revoked-operator-key
    api_base: os.environ/AZURE_API_BASE
    api_version: 2025-04-01-preview
  model_info:
    id: guard-body-api-version-revoked-key-deployment
- model_name: fallback-openai-organization-target
  litellm_params:
    model: openai/gpt-5.4-mini
    api_key: os.environ/OPENAI_API_KEY
  model_info:
    id: fallback-openai-organization-target-deployment
- model_name: fallback-azure-ad-token-target
  litellm_params:
    model: azure/gpt-6.1-sol
    api_key: os.environ/AZURE_API_KEY
    api_base: os.environ/AZURE_API_BASE
    api_version: 2025-04-01-preview
  model_info:
    id: fallback-azure-ad-token-target-deployment
router_settings:
  redis_host: 127.0.0.1
  redis_port: 46391
  cooldown_time: 60
  num_retries: 0
  fallbacks:
  - fallback-openai-organization:
    - fallback-openai-organization-target
  - fallback-azure-ad-token:
    - fallback-azure-ad-token-target
general_settings:
  master_key: os.environ/LITELLM_MASTER_KEY
  allow_client_side_credentials: true
  coordination_redis:
    host: 127.0.0.1
    port: 46391
run_proof.py (the client, exactly as run)
"""usage: run_proof.py <port>. Per scenario: a plain caller, the caller with their own bad field, then two plain callers."""
import json, os, sys, time
import httpx
from scenarios import SCENARIOS
import scenarios as _sc
FALLBACKS = getattr(_sc, "FALLBACKS", {}) if _sc.SCENARIOS is not getattr(_sc, "BEDROCK_SCENARIOS", None) else {}
PORT = sys.argv[1]
HEADERS = {"Authorization": f"Bearer {os.environ['LITELLM_MASTER_KEY']}"}

def body(endpoint, group, stream, extra):
    prompt = "say ok"
    if endpoint == "chat":
        return "/v1/chat/completions", {"model": group, "max_tokens": 256, "messages": [{"role": "user", "content": prompt}], "stream": stream, **extra}
    if endpoint == "messages":
        return "/v1/messages", {"model": group, "max_tokens": 256, "messages": [{"role": "user", "content": prompt}], "stream": stream, **extra}
    return "/v1/responses", {"model": group, "max_output_tokens": 256, "input": prompt, "stream": stream, **extra}

def call(client, endpoint, group, stream, extra):
    query = extra.get("__query__")
    path, payload = body(endpoint, group, stream, {k: v for k, v in extra.items() if k != "__query__"})
    if query:
        path = f"{path}?{query}"
    r = client.post(f"http://localhost:{PORT}{path}", json=payload, headers=HEADERS, timeout=120)
    text = r.text
    if r.status_code == 200:
        return r.status_code, "served"
    try:
        msg = json.loads(text)["error"]["message"]
    except Exception:
        msg = text
    return r.status_code, " ".join(str(msg).split())[:90]

with httpx.Client() as client:
    for sid, kind, _p, endpoint, stream, extra, plain_first in SCENARIOS:
        print(f"## {sid} [{kind}] {endpoint}{' stream' if stream else ''} caller sends {json.dumps(extra)}")
        steps = ([("plain caller", {})] if plain_first else []) + [("caller with own field", extra), ("next plain caller", {}), ("next plain caller", {})]
        for i, (label, fields) in enumerate(steps):
            status, note = call(client, endpoint, sid, stream, fields)
            print(f"   {label:<24} -> {status} {note}")
            if label == "caller with own field":
                time.sleep(2)
                if sid in FALLBACKS:
                    for _ in range(2):
                        status, note = call(client, endpoint, f"{sid}-target", stream, {})
                        print(f"   {'plain caller on fallback':<24} -> {status} {note}")

Run with python run_proof.py <port> for the main set, and SCENARIO_SET=bedrock python run_proof.py <port> for the Bedrock set.

Before (edf8d5c)

Every regression scenario locks every other caller out with 429 cooldown, fallback targets included. On /v1/responses for Azure, and on /v1/messages and /v1/responses for OpenAI, the caller's field never reaches the provider, so those routes were never affected. Two Azure calls in this leg hit Azure's own throttling (429 RateLimitError from Azure, not a cooldown).

Main set, edf8d5c
## azure-ad-token-chat [regression] chat caller sends {"azure_ad_token": "not-a-real-token"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: AzureException AuthenticationError - Access denied due to inv
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## azure-ad-token-chat-stream [regression] chat stream caller sends {"azure_ad_token": "not-a-real-token"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: AzureException AuthenticationError - Access denied due to inv
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## azure-ad-token-messages [regression] messages caller sends {"azure_ad_token": "not-a-real-token"}
   plain caller             -> 429 litellm.RateLimitError: AzureException RateLimitError - Your requests to gpt-6.1-sol for g
   caller with own field    -> 401 litellm.AuthenticationError: AzureException AuthenticationError - Access denied due to inv
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## azure-ad-token-responses [regression] responses caller sends {"azure_ad_token": "not-a-real-token"}
   plain caller             -> 429 litellm.RateLimitError: AzureException RateLimitError - { "error": { "message": "Your requ
   caller with own field    -> 429 litellm.RateLimitError: AzureException RateLimitError - { "error": { "message": "Your requ
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## azure-api-version-chat [regression] chat caller sends {"api_version": "1999-01-01"}
   plain caller             -> 200 served
   caller with own field    -> 404 litellm.NotFoundError: AzureException NotFoundError - Resource not found LiteLLM: model gr
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## openai-organization-chat [regression] chat caller sends {"organization": "org-notarealorg000000000000"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: OpenAIException - OpenAI-Organization header should match org
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## openai-organization-chat-stream [regression] chat stream caller sends {"organization": "org-notarealorg000000000000"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: OpenAIException - OpenAI-Organization header should match org
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## openai-organization-messages [regression] messages caller sends {"organization": "org-notarealorg000000000000"}
   plain caller             -> 200 served
   caller with own field    -> 200 served
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## openai-organization-responses [regression] responses caller sends {"organization": "org-notarealorg000000000000"}
   plain caller             -> 200 served
   caller with own field    -> 200 served
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## vertex-location-chat [regression] chat caller sends {"vertex_location": "mars-central1"}
   plain caller             -> 200 served
   caller with own field    -> 404 litellm.NotFoundError: Vertex_aiException - <!DOCTYPE html> <html lang=en> <meta charset=u
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## vertex-location-messages [regression] messages caller sends {"vertex_location": "mars-central1"}
   plain caller             -> 200 served
   caller with own field    -> 404 litellm.NotFoundError: Vertex_aiException - <!DOCTYPE html> <html lang=en> <meta charset=u
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## bedrock-static-keys-chat [unchanged] chat caller sends {"aws_profile_name": null, "aws_access_key_id": "AKIAFAKEFAKEFAKEFAKE", "aws_secret_access_key": "nope"}
   plain caller             -> 200 served
   caller with own field    -> 403 litellm.AuthenticationError: BedrockException Invalid Authentication - {"message":"The sec
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## fallback-openai-organization [regression] chat caller sends {"organization": "org-notarealorg000000000000"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: OpenAIException - OpenAI-Organization header should match org
   plain caller on fallback -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   plain caller on fallback -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## fallback-azure-ad-token [regression] chat caller sends {"azure_ad_token": "not-a-real-token"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: AzureException AuthenticationError - Access denied due to inv
   plain caller on fallback -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   plain caller on fallback -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## guard-operator-key-revoked [guard] chat caller sends {}
   caller with own field    -> 401 litellm.AuthenticationError: AuthenticationError: OpenAIException - Incorrect API key prov
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## guard-ignored-field-on-openai [guard] chat caller sends {"aws_region_name": "us-east-1"}
   caller with own field    -> 401 litellm.AuthenticationError: AuthenticationError: OpenAIException - Incorrect API key prov
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## guard-echoed-api-version [guard] chat caller sends {"api_version": "2025-04-01-preview"}
   caller with own field    -> 401 litellm.AuthenticationError: AzureException AuthenticationError - Access denied due to inv
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## guard-sdk-api-version-query-revoked-key [guard] chat caller sends {"__query__": "api-version=2024-10-21"}
   caller with own field    -> 401 litellm.AuthenticationError: AzureException AuthenticationError - Access denied due to inv
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## guard-body-api-version-revoked-key [guard] chat caller sends {"api_version": "2024-10-21"}
   caller with own field    -> 401 litellm.AuthenticationError: AzureException AuthenticationError - Access denied due to inv
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for
Bedrock set with #53362 applied, edf8d5c
## bedrock-caller-profile-chat [regression] chat caller sends {"aws_profile_name": "no-such-profile"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: BedrockException Invalid Authentication - The config profile 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## bedrock-caller-profile-chat-stream [regression] chat stream caller sends {"aws_profile_name": "no-such-profile"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: BedrockException Invalid Authentication - The config profile 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## bedrock-caller-profile-messages [regression] messages caller sends {"aws_profile_name": "no-such-profile"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: BedrockException Invalid Authentication - The config profile 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## bedrock-caller-profile-responses [regression] responses caller sends {"aws_profile_name": "no-such-profile"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: BedrockException Invalid Authentication - The config profile 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## bedrock-guard-operator-profile-missing [guard] chat caller sends {}
   caller with own field    -> 401 litellm.AuthenticationError: BedrockException Invalid Authentication - The config profile 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## bedrock-guard-echoed-profile [guard] chat caller sends {"aws_profile_name": "no-such-operator-profile"}
   caller with own field    -> 401 litellm.AuthenticationError: BedrockException Invalid Authentication - The config profile 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for

After (05b6c87)

Every regression scenario keeps serving other callers, fallback targets included. Every guard still cools down exactly as before, including a revoked admin key hit by an Azure SDK style ?api-version= query param or a different body api_version.

Main set, 05b6c87
## azure-ad-token-chat [regression] chat caller sends {"azure_ad_token": "not-a-real-token"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: AzureException AuthenticationError - Access denied due to inv
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## azure-ad-token-chat-stream [regression] chat stream caller sends {"azure_ad_token": "not-a-real-token"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: AzureException AuthenticationError - Access denied due to inv
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## azure-ad-token-messages [regression] messages caller sends {"azure_ad_token": "not-a-real-token"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: AzureException AuthenticationError - Access denied due to inv
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## azure-ad-token-responses [regression] responses caller sends {"azure_ad_token": "not-a-real-token"}
   plain caller             -> 200 served
   caller with own field    -> 200 served
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## azure-api-version-chat [regression] chat caller sends {"api_version": "1999-01-01"}
   plain caller             -> 200 served
   caller with own field    -> 404 litellm.NotFoundError: AzureException NotFoundError - Resource not found LiteLLM: model gr
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## openai-organization-chat [regression] chat caller sends {"organization": "org-notarealorg000000000000"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: OpenAIException - OpenAI-Organization header should match org
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## openai-organization-chat-stream [regression] chat stream caller sends {"organization": "org-notarealorg000000000000"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: OpenAIException - OpenAI-Organization header should match org
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## openai-organization-messages [regression] messages caller sends {"organization": "org-notarealorg000000000000"}
   plain caller             -> 200 served
   caller with own field    -> 200 served
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## openai-organization-responses [regression] responses caller sends {"organization": "org-notarealorg000000000000"}
   plain caller             -> 200 served
   caller with own field    -> 200 served
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## vertex-location-chat [regression] chat caller sends {"vertex_location": "mars-central1"}
   plain caller             -> 200 served
   caller with own field    -> 404 litellm.NotFoundError: Vertex_aiException - <!DOCTYPE html> <html lang=en> <meta charset=u
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## vertex-location-messages [regression] messages caller sends {"vertex_location": "mars-central1"}
   plain caller             -> 200 served
   caller with own field    -> 404 litellm.NotFoundError: Vertex_aiException - <!DOCTYPE html> <html lang=en> <meta charset=u
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## bedrock-static-keys-chat [unchanged] chat caller sends {"aws_profile_name": null, "aws_access_key_id": "AKIAFAKEFAKEFAKEFAKE", "aws_secret_access_key": "nope"}
   plain caller             -> 200 served
   caller with own field    -> 403 litellm.AuthenticationError: BedrockException Invalid Authentication - {"message":"The sec
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## fallback-openai-organization [regression] chat caller sends {"organization": "org-notarealorg000000000000"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: OpenAIException - OpenAI-Organization header should match org
   plain caller on fallback -> 200 served
   plain caller on fallback -> 200 served
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## fallback-azure-ad-token [regression] chat caller sends {"azure_ad_token": "not-a-real-token"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: AzureException AuthenticationError - Access denied due to inv
   plain caller on fallback -> 200 served
   plain caller on fallback -> 200 served
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## guard-operator-key-revoked [guard] chat caller sends {}
   caller with own field    -> 401 litellm.AuthenticationError: AuthenticationError: OpenAIException - Incorrect API key prov
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## guard-ignored-field-on-openai [guard] chat caller sends {"aws_region_name": "us-east-1"}
   caller with own field    -> 401 litellm.AuthenticationError: AuthenticationError: OpenAIException - Incorrect API key prov
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## guard-echoed-api-version [guard] chat caller sends {"api_version": "2025-04-01-preview"}
   caller with own field    -> 401 litellm.AuthenticationError: AzureException AuthenticationError - Access denied due to inv
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## guard-sdk-api-version-query-revoked-key [guard] chat caller sends {"__query__": "api-version=2024-10-21"}
   caller with own field    -> 401 litellm.AuthenticationError: AzureException AuthenticationError - Access denied due to inv
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## guard-body-api-version-revoked-key [guard] chat caller sends {"api_version": "2024-10-21"}
   caller with own field    -> 401 litellm.AuthenticationError: AzureException AuthenticationError - Access denied due to inv
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for
Bedrock set with #53362 applied, 05b6c87
## bedrock-caller-profile-chat [regression] chat caller sends {"aws_profile_name": "no-such-profile"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: BedrockException Invalid Authentication - The config profile 
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## bedrock-caller-profile-chat-stream [regression] chat stream caller sends {"aws_profile_name": "no-such-profile"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: BedrockException Invalid Authentication - The config profile 
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## bedrock-caller-profile-messages [regression] messages caller sends {"aws_profile_name": "no-such-profile"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: BedrockException Invalid Authentication - The config profile 
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## bedrock-caller-profile-responses [regression] responses caller sends {"aws_profile_name": "no-such-profile"}
   plain caller             -> 200 served
   caller with own field    -> 401 litellm.AuthenticationError: BedrockException Invalid Authentication - The config profile 
   next plain caller        -> 200 served
   next plain caller        -> 200 served
## bedrock-guard-operator-profile-missing [guard] chat caller sends {}
   caller with own field    -> 401 litellm.AuthenticationError: BedrockException Invalid Authentication - The config profile 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
## bedrock-guard-echoed-profile [guard] chat caller sends {"aws_profile_name": "no-such-operator-profile"}
   caller with own field    -> 401 litellm.AuthenticationError: BedrockException Invalid Authentication - The config profile 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for 
   next plain caller        -> 429 No deployments available for selected model, Try again in 60 seconds. All deployments for

Recordings

Devin session b31894f9, real Azure, shared deployment, one caller sends its own bad azure_ad_token (recorded at 1acc795acb1, before the rule was simplified, same outcome for this case):

  • Before edf8d5c57ea: video, screenshot. App B gets 429 all_deployments_in_cooldown with no call to Azure
  • After 1acc795acb1: video, screenshot. App B gets 200 from Azure

Black-box tests

tests/integration/routing/test_caller_credential_failure_cooldown.py runs a real proxy against a scripted upstream. Red at the tests-only commit, green three fresh runs in a row at the fix.

Test What the caller sees At tests commit At tip, 3 runs
one caller's rejected credential leaves the deployment serving other callers (azure_ad_token, organization, api_version, bedrock keys, bedrock profile, vertex credentials) other callers get 200, not 429 cooldown red x6 (429 cooldown) green x3
same, with the proxy-wide opt-in instead of the per-deployment one other callers get 200 red x6 green x3
rejected caller credential on a stream (chat for 4 fields, /v1/messages for bedrock keys) other callers get 200 red x5 green x3
rejected caller credential through a fallback (organization, azure_ad_token, api_version) both the primary and the fallback keep serving red x3 green x3
caller's own AWS keys throttled with 429 other callers get 200 red green x3
deployment's own credential rejected (api_key, organization, api_version, bedrock keys) still cools down, guard green x4 green x3
caller resends the deployment's own rejected value still cools down, guard green x4 green x3
SDK-style api_version (body and ?api-version=) with the deployment's key rejected still cools down, guard green x2 green x3
SDK-style api_version with the deployment's own 429 and 500 same cooldown as without the field, guard green x2 green x3
caller organization with the deployment's model missing (404) still cools down, guard green green x3
field the provider ignores, deployment key rejected still cools down, guard green green x3
caller's rejected api_key only that caller fails, guard green green x3

Devin run 75dde093 at tests commit fa855c7f4cf and tip 042389e88d9. Its one broken case (/v1/messages stream with an OpenAI org, which the scripted upstream could not answer, so it 501'd at both commits) was dropped. Confirming runs on 8d803f1417f as the tests commit: b900053e at 1acc795acb1 (21 red, 15 green, then 36/36 three times), and 7d0022b7 at the tip d40072bcb03.

Type

🐛 Bug Fix
✅ Test

Caveats (if any)

Medium

  • A caller field and a broken admin key can fail the same way
    • bad caller organization and revoked admin key both answer 401
    • bad caller api_version and wrong admin deployment name both answer 404
    • that one request then does not cool the deployment, and the admin's plain traffic still does
  • A request with a caller field is judged only by what the caller sent
    • a caller resending a value the deployment takes from an env var, not its config, is not counted
    • same for a caller field the provider ignores, like an Azure AI token next to an api key
  • A 429 or 500 on a request with a caller's own AWS keys does not count, since it is the caller's account
    • the admin's plain traffic still cools a broken deployment
  • Providers not in the table keep today's behavior, a follow-up
    • watsonx, OCI, Databricks and GigaChat credential fields

Low

Final Attestation

  • The tests check the right things, including the edge cases, and regressions in the respective real-world customer use-cases are not possible after this PR

…ployment

A call that ran with a provider credential or target the caller sent (an AWS key or profile, Vertex
credentials or project, an Azure AD token or api_version, an OpenAI organization) and that differs
from the deployment's configured value no longer cools down the shared deployment, so one caller's
bad value cannot lock every other caller out of the model group.
…on every failure path

A caller credential (AWS keys and profile, Vertex credentials, an Azure AD token) is blamed for any
failure, a target (Azure api_version, AWS region, Vertex project and location) only for a 404, and an
OpenAI organization only for a 401 or 403. A value that matches the environment default litellm reads
counts as the deployment's own. Both caller rules now run inside the shared failure exits, so the
walk, a stream that fails before its first chunk and a failed fallback hop all spare the shared
deployment the same way.
@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@veria-ai

veria-ai Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

PR overview

No security issues were found in this pull request.

Reviews

@greptile-apps

greptile-apps Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge with the previous test timing issue fixed.

Summary

The PR keeps caller-owned credential failures from cooling down shared deployments while preserving cooldowns for deployment-owned failures.

The latest change replaces a fixed sleep with a wait for background reports. This addresses the previous finding. No new actionable issues were found.

  • A caller’s rejected credential no longer cools down a shared deployment.

Reviews (6) · Last reviewed commit: "test(router): await stream recordings in..." · Reviewed by Greptile

Comment thread tests/unit/test_router/test_router.py Resolved
@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit d40072b. Configure here.

_CallerField("vertex_location", _NOT_FOUND, ("vertex_ai_location",)),
_CallerField("vertex_ai_location", _NOT_FOUND, ("vertex_location",)),
)
_AZURE_FIELDS: Final = (_CallerField("azure_ad_token", _ANY_FAILURE), _CallerField("api_version", _NOT_FOUND))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, non-blocking. With a caller azure_ad_token we skip the cooldown on any failure, so a 429 or 500 from Azure on that request also doesn't count against the deployment. I checked is_caller_credential_failure at this commit and it returns True for 401, 429 and 500 alike. Probably fine since other callers' failures still count, but maybe worth limiting the token to 401/403 like organization? In this PR or a follow-up at some point

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, done in 05b6c87. A caller Azure token or Vertex credentials now only spare the deployment on a 401 or 403.

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

Comment thread tests/unit/test_router/test_router.py Resolved
@ryan-crabbe-berri

Copy link
Copy Markdown
Contributor Author

@greptileai

@mateo-berri mateo-berri left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks!

_CallerField("aws_region_name", _NOT_FOUND),
)
_VERTEX_FIELDS: Final = (
_CallerField("vertex_credentials", _AUTH_REJECTED_OR_NOT_FOUND, ("vertex_ai_credentials",)),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit, non-blocking. Caller vertex_credentials now skip the cooldown on any 404, even when the deployment sets its own project. I ran it on the integration rig with a deployment that has vertex_project set and a model the provider answers 404 for everyone. Before this PR the next caller got the cooled down group. Now, if the failing caller sent their own valid credentials, the deployment is never cooled down, and the request still went to the deployment's project, so the caller's credentials could not have caused the 404. Maybe only count the 404 against the caller when the deployment has no project set? In this PR or a follow-up at some point

Also reran the Azure token case on the rig after your fix, 429 and 500 cool the group down again, and the 36 integration tests pass

@ryan-crabbe-berri
ryan-crabbe-berri merged commit 23ca457 into main Nov 22, 2026
47 checks passed
@ryan-crabbe-berri
ryan-crabbe-berri deleted the litellm_clientside_cred_cooldown_scope branch November 22, 2026 01:09
mateo-berri added a commit to vanshsingh3711-wq/litellm that referenced this pull request Nov 23, 2026
Main's BerriAI#53431 added a provider-field is_caller_credential_failure next to the Entra check. The PR's Entra or Databricks OAuth check is now is_caller_oauth_credential_failure, and the Rust router's health callbacks call it in place of the old Entra name, so the alias goes away. The shared helper reuses main's _call_credential_values and _configured_by_precedence

_RejectionT drops its Final, since main's LIT010 now flags a Final type variable
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants