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]

fix regen keys when no duration is passed

Ishaan Jaff428762542c37
diff --git a/litellm/proxy/management_endpoints/key_management_endpoints.py b/litellm/proxy/management_endpoints/key_management_endpoints.py
index ec17358e154..3173e38864c 100644
--- a/litellm/proxy/management_endpoints/key_management_endpoints.py
+++ b/litellm/proxy/management_endpoints/key_management_endpoints.py
@@ -293,12 +293,12 @@ async def prepare_key_update_data(
continue
if v is not None and v not in ([], {}, 0):
non_default_values[k] = v
-
if "duration" in non_default_values:
duration = non_default_values.pop("duration")
- duration_s = _duration_in_seconds(duration=duration)
- expires = datetime.now(timezone.utc) + timedelta(seconds=duration_s)
- non_default_values["expires"] = expires
+ if duration and (isinstance(duration, str)) and len(duration) > 0:
+ duration_s = _duration_in_seconds(duration=duration)
+ expires = datetime.now(timezone.utc) + timedelta(seconds=duration_s)
+ non_default_values["expires"] = expires
if "budget_duration" in non_default_values:
duration_s = _duration_in_seconds(