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]

Merge branch 'litellm_internal_staging' into litellm_token_verification_query_opt

harish-berri1d62ca0e2394
diff --cc litellm/proxy/proxy_server.py
index f54df469d95,8f676df04cd..ce93f748b00
--- a/litellm/proxy/proxy_server.py
+++ b/litellm/proxy/proxy_server.py
@@@ -2990,29 -2932,14 +2945,36 @@@ class ProxyConfig
):
## INIT PROXY REDIS USAGE CLIENT ##
redis_usage_cache = litellm.cache.cache
- spend_counter_cache.redis_cache = redis_usage_cache
+ spend_counter_cache.attach_redis_cache(
+ redis_usage_cache,
+ default_redis_ttl=litellm.default_redis_ttl,
+ )
+ # Note: PKCE verifier storage uses redis_usage_cache directly (not
+ # user_api_key_cache) to avoid routing all API-key lookups through Redis.
+ if enable_redis_auth_cache is True:
+ user_api_key_cache.attach_redis_cache(
+ redis_usage_cache,
+ default_redis_ttl=litellm.default_redis_ttl,
+ )
+ verbose_proxy_logger.info(
+ "enable_redis_auth_cache=True: attached Redis to "
+ "user_api_key_cache — virtual-key lookups are now "
+ "shared across all proxy workers."
+ )
+ else:
+ verbose_proxy_logger.info(
+ "enable_redis_auth_cache is not set: user_api_key_cache "
+ "remains in-memory only (per-worker). Set "
+ "litellm_settings.enable_redis_auth_cache: true to share "
+ "the auth cache across workers and reduce DB load."
+ )
+ litellm_config_cache.redis_cache = redis_usage_cache
+ # Note: PKCE verifier storage uses redis_usage_cache directly (not
+ # user_api_key_cache) to avoid routing all API-key lookups through Redis.
+ elif litellm_config_cache.redis_cache is None:
+ verbose_proxy_logger.info(
+ "litellm_config_cache: no Redis configured; cluster-wide cache sharing disabled."
+ )
def switch_on_llm_response_caching(self):
"""