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]

Merge branch 'main' into litellm_langfuse-session-trace-fix

Harshit Jain4f04d2648e9b
diff --cc litellm/integrations/langfuse/langfuse.py
index afad3f50940,9d6ddd0f1e9..6ac337d99a9
--- a/litellm/integrations/langfuse/langfuse.py
+++ b/litellm/integrations/langfuse/langfuse.py
@@@ -607,13 -607,10 +607,10 @@@ class LangFuseLogger
# Use standard_logging_object.trace_id if available (when trace_id from metadata is None)
# This allows standard trace_id to be used when provided in standard_logging_object
if trace_id is None and standard_logging_object is not None:
- trace_id = cast(
- Optional[str], standard_logging_object.get("trace_id")
- )
- # Fallback: use litellm_trace_id from kwargs (matches DB session_id),
- # then litellm_call_id as last resort
+ trace_id = cast(Optional[str], standard_logging_object.get("trace_id"))
+ # Fallback to litellm_call_id if no trace_id found
if trace_id is None:
- trace_id = litellm_call_id
+ trace_id = kwargs.get("litellm_trace_id") or litellm_call_id
existing_trace_id = clean_metadata.pop("existing_trace_id", None)
# If existing_trace_id is provided, use it as the trace_id to return
# This allows continuing an existing trace while still returning the correct trace_id