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]

chore(auto-router): document mutable logging API boundaries

Moe Khalilbda1bd89aeef
diff --git a/litellm/router_strategy/complexity_router/jev_classifier.py b/litellm/router_strategy/complexity_router/jev_classifier.py
index acaf19a5aba..ef613f8321d 100644
--- a/litellm/router_strategy/complexity_router/jev_classifier.py
+++ b/litellm/router_strategy/complexity_router/jev_classifier.py
@@ -126,8 +126,8 @@ class HttpJevClassifierClient:
for key, value in TypeAdapter(Mapping[str, object]).validate_python(metadata).items()
}
)
- params: Final = {
- "metadata": {
+ params: Final = { # mutable-ok: Logging's kwargs and litellm_params require dicts
+ "metadata": { # mutable-ok: Logging enriches metadata in place before dispatching callbacks
**forwarded_internal_call_metadata(parent_metadata, AUTOROUTER_CLASSIFIER_CALL_ORIGIN),
INTERNAL_CALL_ORIGIN_METADATA_KEY: AUTOROUTER_CLASSIFIER_CALL_ORIGIN,
},
@@ -136,7 +136,7 @@ class HttpJevClassifierClient:
}
logging_obj: Final = Logging(
model=f"typesafe/{request.model}",
- messages=[{"role": "user", "content": request.state}],
+ messages=[{"role": "user", "content": request.state}], # mutable-ok: callbacks require JSON message lists
stream=False,
call_type="pass_through_endpoint",
start_time=start_time,
@@ -148,7 +148,7 @@ class HttpJevClassifierClient:
logging_obj.update_environment_variables(
model=f"typesafe/{request.model}",
user=parent_user if isinstance(parent_user := parent.get("user"), str) else None,
- optional_params={},
+ optional_params={}, # mutable-ok: Logging's optional_params contract requires a dict
litellm_params=params,
)
normalized: Final = TypeSafePassthroughLoggingHandler.typesafe_passthrough_handler(