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
fix: URL encode OTEL_EXPORTER_OTLP_TRACES_HEADERS for Phoenix Integration (#10654)
Dat Daryl Ngof1136fd217f1
diff --git a/litellm/integrations/arize/arize_phoenix.py b/litellm/integrations/arize/arize_phoenix.pyindex 2b4909885a3..044486fcd27 100644--- a/litellm/integrations/arize/arize_phoenix.py+++ b/litellm/integrations/arize/arize_phoenix.py@@ -1,4 +1,5 @@import os+import urllib.parsefrom typing import TYPE_CHECKING, Any, Unionfrom litellm._logging import verbose_logger@@ -69,7 +70,7 @@ class ArizePhoenixLogger:otlp_auth_headers = f"api_key={api_key}"elif api_key is not None:# api_key/auth is optional for self hosted phoenix- otlp_auth_headers = f"Authorization=Bearer {api_key}"+ otlp_auth_headers = f"Authorization={urllib.parse.quote(f'Bearer {api_key}')}"return ArizePhoenixConfig(otlp_auth_headers=otlp_auth_headers, protocol=protocol, endpoint=endpointdiff --git a/tests/litellm/integrations/arize/test_arize_phoenix.py b/tests/litellm/integrations/arize/test_arize_phoenix.pynew file mode 100644index 00000000000..a7acab986e0--- /dev/null+++ b/tests/litellm/integrations/arize/test_arize_phoenix.py@@ -0,0 +1,34 @@+import unittest+from unittest.mock import patch+from litellm.integrations.arize.arize_phoenix import ArizePhoenixLogger++class TestArizePhoenixConfig(unittest.TestCase):++ @patch.dict('os.environ', {+ 'PHOENIX_API_KEY': 'test_api_key',+ 'PHOENIX_COLLECTOR_HTTP_ENDPOINT': 'http://test.endpoint'+ })+ def test_get_arize_phoenix_config_http(self):+ # Call the function to get the configuration+ config = ArizePhoenixLogger.get_arize_phoenix_config()++ # Verify the configuration+ self.assertEqual(config.otlp_auth_headers, 'Authorization=Bearer%20test_api_key')+ self.assertEqual(config.endpoint, 'http://test.endpoint')+ self.assertEqual(config.protocol, 'otlp_http')++ @patch.dict('os.environ', {+ 'PHOENIX_API_KEY': 'test_api_key',+ 'PHOENIX_COLLECTOR_ENDPOINT': 'grpc://test.endpoint'+ })+ def test_get_arize_phoenix_config_grpc(self):+ # Call the function to get the configuration+ config = ArizePhoenixLogger.get_arize_phoenix_config()++ # Verify the configuration+ self.assertEqual(config.otlp_auth_headers, 'Authorization=Bearer%20test_api_key')+ self.assertEqual(config.endpoint, 'grpc://test.endpoint')+ self.assertEqual(config.protocol, 'otlp_grpc')++if __name__ == '__main__':+ unittest.main()\ No newline at end of file