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 remote-tracking branch 'origin/litellm_internal_staging' into litellm_token_verification_query_opt

harish-berria9761e1e742d
diff --cc litellm/proxy/auth/user_api_key_auth.py
index bd7b531633a,9779a07b97b..16b44a4d486
--- a/litellm/proxy/auth/user_api_key_auth.py
+++ b/litellm/proxy/auth/user_api_key_auth.py
@@@ -1467,17 -1457,14 +1472,22 @@@ async def _user_api_key_auth_builder(
else:
_team_obj = None
+ if _team_obj is not None:
+ valid_token.team_object_permission = _team_obj.object_permission
+ else:
+ valid_token.team_object_permission = None
+
- await user_api_key_cache.async_set_cache(
- key=valid_token.team_id, value=_team_obj
- ) # save team table in cache - used for tpm/rpm limiting - tpm_rpm_limiter.py
+ # Only cache when the key is a real team_id (non-team keys must not use key=None).
+ if valid_token.team_id is not None and _team_obj is not None:
+ # Match get_team_object / spend counters: "team_id:{id}". Serialize for Redis
+ # (json.dumps) — same as _cache_team_object in auth_checks.
+ team_cache_key = f"team_id:{valid_token.team_id}"
+ await user_api_key_cache.async_set_cache(
+ key=team_cache_key,
+ value=CacheCodec.serialize(
+ _team_obj, model_type=LiteLLM_TeamTableCachedObj
+ ),
+ ) # save team table in cache - used for tpm/rpm limiting - tpm_rpm_limiter.py
# Fetch project object if key belongs to a project
_project_obj = None