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
Merge branch 'litellm_yj_may1' into codex/budget-race-enforcement
yuneng-jiangc2cea585670a
diff --cc litellm/proxy/_lazy_openapi_snapshot.pyindex a51cb173dd5,f9519cc17c1..de118a66d98--- a/litellm/proxy/_lazy_openapi_snapshot.py+++ b/litellm/proxy/_lazy_openapi_snapshot.py@@@ -8,27 -8,23 +8,37 @@@ any drift as a neutral check"""import json+import reimport sysfrom pathlib import Path- from typing import Dict, Optional+ from typing import Dict, Optional, SetSNAPSHOT_FILE = Path(__file__).parent / "_lazy_openapi_snapshot.json"+ HTTP_METHOD_SUFFIXES = {+ "delete",+ "get",+ "head",+ "options",+ "patch",+ "post",+ "put",+ "trace",+ }+def _stabilize_multi_method_route_ids(routes) -> None:+ """FastAPI derives route IDs from a set of methods; make snapshots stable."""++ for route in routes:+ methods = sorted(getattr(route, "methods", None) or [])+ if len(methods) <= 1 or not getattr(route, "path_format", None):+ continue++ operation_id = f"{route.name}{route.path_format}"+ operation_id = re.sub(r"\W", "_", operation_id)+ route.unique_id = f"{operation_id}_{methods[0].lower()}"++def load_snapshot() -> Optional[Dict[str, Dict]]:if not SNAPSHOT_FILE.exists():return None@@@ -65,15 -95,25 +109,26 @@@ def generate_snapshot() -> Dict[str, Di]if not feat_routes:continue+ _stabilize_multi_method_route_ids(feat_routes)full = get_openapi(title=app.title, version=app.version, routes=feat_routes)+ paths = full.get("paths", {})+ _normalize_operation_ids(paths)# Group all of a feature's routes under one tag.for path_ops in full.get("paths", {}).values():- for op in path_ops.values():+ for method, op in path_ops.items():if isinstance(op, dict):+ operation_id = op.get("operationId")+ if isinstance(operation_id, str):+ for suffix in HTTP_METHOD_SUFFIXES:+ if operation_id.endswith(f"_{suffix}"):+ op["operationId"] = (+ operation_id[: -len(suffix)] + method+ )+ breakop["tags"] = [feat.name]+ full = ensure_unique_openapi_operation_ids(full, used_operation_ids)fragments[feat.name] = {- "paths": full.get("paths", {}),+ "paths": paths,"components": {"schemas": full.get("components", {}).get("schemas", {})},}return fragments