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]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
feat: Validate LiteLLM Virtual Key format (#14428)
Ishaan Jaffc09d9e5e8e71
diff --git a/litellm/proxy/management_endpoints/key_management_endpoints.py b/litellm/proxy/management_endpoints/key_management_endpoints.pyindex 0bf957f2656..bd8faf34be8 100644--- a/litellm/proxy/management_endpoints/key_management_endpoints.py+++ b/litellm/proxy/management_endpoints/key_management_endpoints.py@@ -551,6 +551,15 @@ async def _common_key_generation_helper( # noqa: PLR0915prisma_client=prisma_client,)+ # Validate user-provided key format+ if data.key is not None and not data.key.startswith("sk-"):+ raise HTTPException(+ status_code=400,+ detail={+ "error": f"Invalid key format. LiteLLM Virtual Key must start with 'sk-'. Received: {data.key}"+ }+ )+response = await generate_key_helper_fn(request_type="key", **data_json, table_name="key")