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
use itellm.forward_traceparent_to_llm_provider
Ishaan Jaff70c836623d27
diff --git a/litellm/__init__.py b/litellm/__init__.pyindex 72aeb74d994..cc03867cff2 100644--- a/litellm/__init__.py+++ b/litellm/__init__.py@@ -165,6 +165,7 @@ budget_duration: Optional[str] = (default_soft_budget: float = (50.0 # by default all litellm proxy keys have a soft budget of 50.0)+forward_traceparent_to_llm_provider: bool = False_openai_finish_reasons = ["stop", "length", "function_call", "content_filter", "null"]_openai_completion_params = ["functions",diff --git a/litellm/proxy/litellm_pre_call_utils.py b/litellm/proxy/litellm_pre_call_utils.pyindex ffea850a336..13f9475c5c7 100644--- a/litellm/proxy/litellm_pre_call_utils.py+++ b/litellm/proxy/litellm_pre_call_utils.py@@ -3,6 +3,7 @@ from typing import TYPE_CHECKING, Any, Dict, Optionalfrom fastapi import Request+import litellmfrom litellm._logging import verbose_logger, verbose_proxy_loggerfrom litellm.proxy._types import CommonProxyErrors, TeamCallbackMetadata, UserAPIKeyAuthfrom litellm.types.utils import SupportedCacheControls@@ -250,13 +251,15 @@ def _add_otel_traceparent_to_data(data: dict, request: Request):# if user is not use OTEL don't send extra_headers# relevant issue: https://github.com/BerriAI/litellm/issues/4448return- if request.headers:- if "traceparent" in request.headers:- # we want to forward this to the LLM Provider- # Relevant issue: https://github.com/BerriAI/litellm/issues/4419- # pass this in extra_headers- if "extra_headers" not in data:- data["extra_headers"] = {}- _exra_headers = data["extra_headers"]- if "traceparent" not in _exra_headers:- _exra_headers["traceparent"] = request.headers["traceparent"]++ if litellm.forward_traceparent_to_llm_provider is True:+ if request.headers:+ if "traceparent" in request.headers:+ # we want to forward this to the LLM Provider+ # Relevant issue: https://github.com/BerriAI/litellm/issues/4419+ # pass this in extra_headers+ if "extra_headers" not in data:+ data["extra_headers"] = {}+ _exra_headers = data["extra_headers"]+ if "traceparent" not in _exra_headers:+ _exra_headers["traceparent"] = request.headers["traceparent"]