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: resolve conflict with main in otel metadata module
yucheng126e257062b7
diff --cc litellm/integrations/otel/model/metadata.pyindex 2fdbc826803,5f90e70e119..dd4247ad3d0--- a/litellm/integrations/otel/model/metadata.py+++ b/litellm/integrations/otel/model/metadata.py@@@ -49,6 -48,10 +49,9 @@@ from litellm.integrations.otel.model.utif TYPE_CHECKING:from litellm.types.utils import StandardLoggingPayload-LANGFUSE_TRACE_NAME_HEADER: Final = "langfuse_trace_name"+ REQUESTER_METADATA_KEY: Final = "requester_metadata"+ REQUESTER_METADATA_PATH: Final = f"{REQUESTER_METADATA_KEY}."+@dataclass(frozen=True)class RequestIdentity:@@@ -323,6 -359,35 +332,35 @@@ def model_from_request_data(data: objecreturn None+ def metadata_from_request_data(data: object) -> Mapping[str, object] | None:+ """The caller's ``requester_metadata`` snapshot from a pre-call ``data`` dict, keyed under its wrapper.++ The proxy stores it under ``metadata`` or ``litellm_metadata`` depending on the route;+ the proxy-owned siblings (``user_api_key_*``, ``requester_ip_address``) are not read.+ """- top: Final = _as_str_mapping(data)++ top: Final = as_str_mapping(data)+ if top is None:+ return None+ snapshots: Final = tuple(+ snapshot+ for name in ("metadata", "litellm_metadata")- if (nested := _as_str_mapping(top.get(name))) is not None- and (snapshot := _as_str_mapping(nested.get(REQUESTER_METADATA_KEY))) is not None++ if (nested := as_str_mapping(top.get(name))) is not None++ and (snapshot := as_str_mapping(nested.get(REQUESTER_METADATA_KEY))) is not None+ )+ return MappingProxyType({REQUESTER_METADATA_KEY: snapshots[0]}) if snapshots else None+++ def flatten_metadata(raw: Mapping[str, object]) -> Iterator[tuple[str, str]]:+ """Scalar leaves of a nested metadata mapping, keyed by their dotted path."""+ stack: Final = list(tuple(raw.items())[::-1]) # mutable-ok: iterative worklist keeps the walk off the call stack+ while stack:+ key, value = stack.pop()- if (nested := _as_str_mapping(value)) is not None:++ if (nested := as_str_mapping(value)) is not None:+ stack.extend(tuple((f"{key}.{sub_key}", sub_value) for sub_key, sub_value in nested.items())[::-1])+ elif isinstance(value, (str, bool, int, float)):+ yield key, str(value)++def resolve_provider_model(payload: StandardLoggingPayload) -> str | None:"""The model litellm dispatched to the provider, from the payload.