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
April 21st Ishaan Branch (#26213)
ishaan-berri0e42d4cb0857
diff --git a/litellm/integrations/opentelemetry.py b/litellm/integrations/opentelemetry.pyindex 7ff360758e8..b6d91d0b76d 100644--- a/litellm/integrations/opentelemetry.py+++ b/litellm/integrations/opentelemetry.py@@ -2289,6 +2289,10 @@ class OpenTelemetry(CustomLogger):# Remove trailing slashendpoint = endpoint.rstrip("/")+ # Splunk Observability Cloud OTLP/HTTP uses /v2/trace/otlp (not /v1/traces). Do not rewrite.+ if signal_type == "traces" and "/v2/trace/otlp" in endpoint:+ return endpoint+# Check if endpoint already ends with the correct signal pathtarget_path = f"/v1/{signal_type}"if endpoint.endswith(target_path):diff --git a/model_prices_and_context_window.json b/model_prices_and_context_window.jsonindex 303c48717f5..4e629bbd947 100644--- a/model_prices_and_context_window.json+++ b/model_prices_and_context_window.json@@ -25165,6 +25165,28 @@"supports_vision": true,"tool_use_system_prompt_tokens": 346},+ "openrouter/anthropic/claude-opus-4.7": {+ "cache_creation_input_token_cost": 6.25e-06,+ "cache_read_input_token_cost": 5e-07,+ "input_cost_per_token": 5e-06,+ "litellm_provider": "openrouter",+ "max_input_tokens": 1000000,+ "max_output_tokens": 128000,+ "max_tokens": 128000,+ "mode": "chat",+ "output_cost_per_token": 2.5e-05,+ "supports_assistant_prefill": false,+ "supports_computer_use": true,+ "supports_function_calling": true,+ "supports_pdf_input": true,+ "supports_prompt_caching": true,+ "supports_reasoning": true,+ "supports_response_schema": true,+ "supports_tool_choice": true,+ "supports_vision": true,+ "supports_xhigh_reasoning_effort": true,+ "tool_use_system_prompt_tokens": 346+ },"openrouter/bytedance/ui-tars-1.5-7b": {"input_cost_per_token": 1e-07,"litellm_provider": "openrouter",diff --git a/tests/test_litellm/integrations/test_opentelemetry.py b/tests/test_litellm/integrations/test_opentelemetry.pyindex e723298b1c9..f7106471894 100644--- a/tests/test_litellm/integrations/test_opentelemetry.py+++ b/tests/test_litellm/integrations/test_opentelemetry.py@@ -1047,6 +1047,36 @@ class TestOpenTelemetryEndpointNormalization(unittest.TestCase):result = otel._normalize_otel_endpoint("http://collector:4318/", "traces")self.assertEqual(result, "http://collector:4318/v1/traces")+ @parameterized.expand(+ [+ (+ "https://ingest.eu1.observability.splunkcloud.com/v2/trace/otlp",+ "https://ingest.eu1.observability.splunkcloud.com/v2/trace/otlp",+ ),+ (+ "https://ingest.us0.observability.splunkcloud.com/v2/trace/otlp/",+ "https://ingest.us0.observability.splunkcloud.com/v2/trace/otlp",+ ),+ (+ "https://ingest.eu0.signalfx.com/v2/trace/otlp",+ "https://ingest.eu0.signalfx.com/v2/trace/otlp",+ ),+ (+ "https://example.com/prefix/v2/trace/otlp",+ "https://example.com/prefix/v2/trace/otlp",+ ),+ ]+ )+ def test_normalize_traces_nonstandard_otlp_ingest_urls_unchanged(+ self, input_url: str, expected: str+ ) -> None:+ """Splunk-style /v2/trace/otlp endpoints must not get /v1/traces appended."""+ otel = OpenTelemetry()+ self.assertEqual(+ otel._normalize_otel_endpoint(input_url, "traces"),+ expected,+ )+def test_normalize_endpoint_none(self):"""Test that None endpoint returns None"""otel = OpenTelemetry()@@ -1315,7 +1345,7 @@ class TestOpenTelemetryProtocolSelection(unittest.TestCase):@patch.dict(os.environ,{- "OTEL_EXPORTER": "otlp_http",+ "OTEL_EXPORTER_OTLP_PROTOCOL": "http/protobuf","OTEL_EXPORTER_OTLP_ENDPOINT": "http://collector:4318",},clear=False,@@ -1339,7 +1369,7 @@ class TestOpenTelemetryProtocolSelection(unittest.TestCase):@patch.dict(os.environ,{- "OTEL_EXPORTER": "otlp_grpc",+ "OTEL_EXPORTER_OTLP_PROTOCOL": "grpc","OTEL_EXPORTER_OTLP_ENDPOINT": "http://collector:4317",},clear=False,@@ -1360,6 +1390,60 @@ class TestOpenTelemetryProtocolSelection(unittest.TestCase):self.assertIsInstance(processor, BatchSpanProcessor)self.assertIsInstance(processor.span_exporter, OTLPSpanExporterGRPC)+ @patch.dict(+ os.environ,+ {+ "OTEL_EXPORTER": "otlp_http",+ "OTEL_EXPORTER_OTLP_ENDPOINT": "http://collector:4318",+ },+ clear=False,+ )+ def test_protocol_selection_from_otel_exporter_fallback_http(self):+ """OTEL_EXPORTER drives protocol when OTEL_EXPORTER_OTLP_PROTOCOL is unset."""+ from opentelemetry.exporter.otlp.proto.http.trace_exporter import (+ OTLPSpanExporter as OTLPSpanExporterHTTP,+ )+ from opentelemetry.sdk.trace.export import BatchSpanProcessor++ popped_protocol = os.environ.pop("OTEL_EXPORTER_OTLP_PROTOCOL", None)+ try:+ config = OpenTelemetryConfig.from_env()+ self.assertEqual(config.exporter, "otlp_http")+ otel = OpenTelemetry(config=config)+ processor = otel._get_span_processor()+ self.assertIsInstance(processor, BatchSpanProcessor)+ self.assertIsInstance(processor.span_exporter, OTLPSpanExporterHTTP)+ finally:+ if popped_protocol is not None:+ os.environ["OTEL_EXPORTER_OTLP_PROTOCOL"] = popped_protocol++ @patch.dict(+ os.environ,+ {+ "OTEL_EXPORTER": "otlp_grpc",+ "OTEL_EXPORTER_OTLP_ENDPOINT": "http://collector:4317",+ },+ clear=False,+ )+ def test_protocol_selection_from_otel_exporter_fallback_grpc(self):+ """OTEL_EXPORTER drives protocol when OTEL_EXPORTER_OTLP_PROTOCOL is unset."""+ from opentelemetry.exporter.otlp.proto.grpc.trace_exporter import (+ OTLPSpanExporter as OTLPSpanExporterGRPC,+ )+ from opentelemetry.sdk.trace.export import BatchSpanProcessor++ popped_protocol = os.environ.pop("OTEL_EXPORTER_OTLP_PROTOCOL", None)+ try:+ config = OpenTelemetryConfig.from_env()+ self.assertEqual(config.exporter, "otlp_grpc")+ otel = OpenTelemetry(config=config)+ processor = otel._get_span_processor()+ self.assertIsInstance(processor, BatchSpanProcessor)+ self.assertIsInstance(processor.span_exporter, OTLPSpanExporterGRPC)+ finally:+ if popped_protocol is not None:+ os.environ["OTEL_EXPORTER_OTLP_PROTOCOL"] = popped_protocol+def test_http_exporter_endpoint_normalization_for_traces(self):"""Test that HTTP trace exporter gets properly normalized endpoint"""config = OpenTelemetryConfig(