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]

fix(callbacks): preserve langfuse secret alias

userbb6d7c9715dc
diff --git a/litellm/integrations/langfuse/langfuse_handler.py b/litellm/integrations/langfuse/langfuse_handler.py
index 3552054bcd4..4a809726424 100644
--- a/litellm/integrations/langfuse/langfuse_handler.py
+++ b/litellm/integrations/langfuse/langfuse_handler.py
@@ -115,7 +115,8 @@ class LangFuseHandler:
langfuse_logger = LangFuseLogger(
langfuse_public_key=credentials.get("langfuse_public_key"),
- langfuse_secret=credentials.get("langfuse_secret"),
+ langfuse_secret=credentials.get("langfuse_secret")
+ or credentials.get("langfuse_secret_key"),
langfuse_host=credentials.get("langfuse_host"),
allow_env_credentials=credentials.get("langfuse_host") is None,
)
diff --git a/tests/logging_callback_tests/test_langfuse_dynamic_credentials.py b/tests/logging_callback_tests/test_langfuse_dynamic_credentials.py
index 14478649ad3..1b198623381 100644
--- a/tests/logging_callback_tests/test_langfuse_dynamic_credentials.py
+++ b/tests/logging_callback_tests/test_langfuse_dynamic_credentials.py
@@ -3,6 +3,7 @@ from types import ModuleType, SimpleNamespace
import litellm
from litellm.integrations.langfuse.langfuse import resolve_langfuse_credentials
+from litellm.integrations.langfuse.langfuse_handler import LangFuseHandler
def test_resolve_langfuse_credentials_does_not_use_env_for_dynamic_host(monkeypatch):
@@ -81,3 +82,48 @@ def test_upstream_langfuse_debug_env_is_passed(monkeypatch):
assert logger.upstream_langfuse_debug == "true"
assert FakeLangfuse.instances[-1].kwargs["debug"] is True
+
+
+def test_langfuse_handler_accepts_secret_key_alias(monkeypatch):
+ captured = {}
+
+ class FakeLangFuseLogger:
+ def __init__(
+ self,
+ *,
+ langfuse_public_key=None,
+ langfuse_secret=None,
+ langfuse_host=None,
+ allow_env_credentials=True,
+ ):
+ captured["langfuse_public_key"] = langfuse_public_key
+ captured["langfuse_secret"] = langfuse_secret
+ captured["langfuse_host"] = langfuse_host
+ captured["allow_env_credentials"] = allow_env_credentials
+
+ class FakeDynamicLoggingCache:
+ def set_cache(self, *, credentials, service_name, logging_obj):
+ captured["cached_credentials"] = credentials
+ captured["cached_service_name"] = service_name
+ captured["cached_logging_obj"] = logging_obj
+
+ monkeypatch.setattr(
+ "litellm.integrations.langfuse.langfuse_handler.LangFuseLogger",
+ FakeLangFuseLogger,
+ )
+
+ logger = LangFuseHandler._create_langfuse_logger_from_credentials(
+ credentials={
+ "langfuse_public_key": "dynamic-public",
+ "langfuse_secret_key": "dynamic-secret",
+ "langfuse_host": "https://langfuse.example",
+ },
+ in_memory_dynamic_logger_cache=FakeDynamicLoggingCache(),
+ )
+
+ assert captured["langfuse_public_key"] == "dynamic-public"
+ assert captured["langfuse_secret"] == "dynamic-secret"
+ assert captured["langfuse_host"] == "https://langfuse.example"
+ assert captured["allow_env_credentials"] is False
+ assert captured["cached_service_name"] == "langfuse"
+ assert captured["cached_logging_obj"] is logger