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
Litellm dev 07 03 2025 p2 (#12301)
Krish Dholakiaa03390ccc734
diff --git a/docs/my-website/docs/observability/langfuse_integration.md b/docs/my-website/docs/observability/langfuse_integration.mdindex 34b213f0e21..b6d8c836520 100644--- a/docs/my-website/docs/observability/langfuse_integration.md+++ b/docs/my-website/docs/observability/langfuse_integration.md@@ -11,6 +11,13 @@ Example trace in Langfuse using multiple models via LiteLLM:<Image img={require('../../img/langfuse-example-trace-multiple-models-min.png')} />+:::info++For Langfuse v3, we recommend using the [Langfuse OTEL](./langfuse_otel_integration) integration.++:::++## Usage with LiteLLM Proxy (LLM Gateway)👉 [**Follow this link to start sending logs to langfuse with LiteLLM Proxy server**](../proxy/logging)diff --git a/docs/my-website/docs/observability/langfuse_otel_integration.md b/docs/my-website/docs/observability/langfuse_otel_integration.mdindex 267738c3003..c45c33f0f25 100644--- a/docs/my-website/docs/observability/langfuse_otel_integration.md+++ b/docs/my-website/docs/observability/langfuse_otel_integration.md@@ -1,7 +1,14 @@-# Langfuse OpenTelemetry Integration+import Tabs from '@theme/Tabs';+import TabItem from '@theme/TabItem';++import Image from '@theme/IdealImage';++# 🪢 Langfuse OpenTelemetry IntegrationThe Langfuse OpenTelemetry integration allows you to send LiteLLM traces and observability data to Langfuse using the OpenTelemetry protocol. This provides a standardized way to collect and analyze your LLM usage data.+<Image img={require('../../img/langfuse_otel.png')} />+## Features- Automatic trace collection for all LiteLLM requests@@ -108,15 +115,26 @@ litellm.callbacks = ["langfuse_otel"]Add the integration to your proxy configuration:+1. Add the credentials to your environment variables++```bash+export LANGFUSE_PUBLIC_KEY="pk-lf-..."+export LANGFUSE_SECRET_KEY="sk-lf-..."+export LANGFUSE_HOST="https://us.cloud.langfuse.com" # Default US region+```++2. Setup config.yaml+```yaml# config.yamllitellm_settings:callbacks: ["langfuse_otel"]+```++3. Run the proxy-environment_variables:- LANGFUSE_PUBLIC_KEY: "pk-lf-..."- LANGFUSE_SECRET_KEY: "sk-lf-..."- LANGFUSE_HOST: "https://us.cloud.langfuse.com" # Default US region+```bash+litellm --config /path/to/config.yaml```## Data Collected@@ -163,11 +181,24 @@ This is automatically handled by the integration - you just need to provide theEnable verbose logging to see detailed information:+<Tabs>+<TabItem value="sdk" label="SDK">+```pythonimport litellm-litellm.set_verbose = True+litellm._turn_on_debug()```+</TabItem>+<TabItem value="proxy" label="PROXY">++```bash+export LITELLM_LOG="DEBUG"+```++</TabItem>+</Tabs>+This will show:- Endpoint resolution logic- Authentication header creationdiff --git a/docs/my-website/docs/proxy/prompt_management.md b/docs/my-website/docs/proxy/prompt_management.mdindex 8ea17425c82..fc35fc5ef38 100644--- a/docs/my-website/docs/proxy/prompt_management.md+++ b/docs/my-website/docs/proxy/prompt_management.md@@ -210,6 +210,7 @@ These are the params you can pass to the `litellm.completion` function in SDK an```prompt_id: str # requiredprompt_variables: Optional[dict] # optional+prompt_version: Optional[int] # optionallangfuse_public_key: Optional[str] # optionallangfuse_secret: Optional[str] # optionallangfuse_secret_key: Optional[str] # optionaldiff --git a/docs/my-website/img/langfuse_otel.png b/docs/my-website/img/langfuse_otel.pngnew file mode 100644index 00000000000..a91e337f2c5Binary files /dev/null and b/docs/my-website/img/langfuse_otel.png differdiff --git a/litellm/integrations/anthropic_cache_control_hook.py b/litellm/integrations/anthropic_cache_control_hook.pyindex 5c75e452ab7..29d9920da43 100644--- a/litellm/integrations/anthropic_cache_control_hook.py+++ b/litellm/integrations/anthropic_cache_control_hook.py@@ -29,6 +29,7 @@ class AnthropicCacheControlHook(CustomPromptManagement):prompt_variables: Optional[dict],dynamic_callback_params: StandardCallbackDynamicParams,prompt_label: Optional[str] = None,+ prompt_version: Optional[int] = None,) -> Tuple[str, List[AllMessageValues], dict]:"""Apply cache control directives based on specified injection points.@@ -80,10 +81,10 @@ class AnthropicCacheControlHook(CustomPromptManagement):# Case 1: Target by specific indexif targetted_index is not None:if 0 <= targetted_index < len(messages):- messages[- targetted_index- ] = AnthropicCacheControlHook._safe_insert_cache_control_in_message(- messages[targetted_index], control+ messages[targetted_index] = (+ AnthropicCacheControlHook._safe_insert_cache_control_in_message(+ messages[targetted_index], control+ ))# Case 2: Target by roleelif targetted_role is not None:diff --git a/litellm/integrations/custom_logger.py b/litellm/integrations/custom_logger.pyindex 890482761a5..a9cbc65e6f4 100644--- a/litellm/integrations/custom_logger.py+++ b/litellm/integrations/custom_logger.py@@ -89,6 +89,7 @@ class CustomLogger: # https://docs.litellm.ai/docs/observability/custom_callbaclitellm_logging_obj: LiteLLMLoggingObj,tools: Optional[List[Dict]] = None,prompt_label: Optional[str] = None,+ prompt_version: Optional[int] = None,) -> Tuple[str, List[AllMessageValues], dict]:"""Returns:@@ -107,6 +108,7 @@ class CustomLogger: # https://docs.litellm.ai/docs/observability/custom_callbacprompt_variables: Optional[dict],dynamic_callback_params: StandardCallbackDynamicParams,prompt_label: Optional[str] = None,+ prompt_version: Optional[int] = None,) -> Tuple[str, List[AllMessageValues], dict]:"""Returns:@@ -408,9 +410,10 @@ class CustomLogger: # https://docs.litellm.ai/docs/observability/custom_callbacif len(text) > max_lengthelse text)-- def _select_metadata_field(self, request_kwargs: Optional[Dict] = None) -> Optional[str]:+ def _select_metadata_field(+ self, request_kwargs: Optional[Dict] = None+ ) -> Optional[str]:"""Select the metadata field to use for logging@@ -418,9 +421,9 @@ class CustomLogger: # https://docs.litellm.ai/docs/observability/custom_callbac2. Otherwise, use `metadata`"""from litellm.constants import LITELLM_METADATA_FIELD, OLD_LITELLM_METADATA_FIELD+if request_kwargs is None:return Noneif LITELLM_METADATA_FIELD in request_kwargs:return LITELLM_METADATA_FIELDreturn OLD_LITELLM_METADATA_FIELD-\ No newline at end of filediff --git a/litellm/integrations/custom_prompt_management.py b/litellm/integrations/custom_prompt_management.pyindex 061aadc3c05..86cd1dc9f75 100644--- a/litellm/integrations/custom_prompt_management.py+++ b/litellm/integrations/custom_prompt_management.py@@ -19,6 +19,7 @@ class CustomPromptManagement(CustomLogger, PromptManagementBase):prompt_variables: Optional[dict],dynamic_callback_params: StandardCallbackDynamicParams,prompt_label: Optional[str] = None,+ prompt_version: Optional[int] = None,) -> Tuple[str, List[AllMessageValues], dict]:"""Returns:@@ -45,6 +46,7 @@ class CustomPromptManagement(CustomLogger, PromptManagementBase):prompt_variables: Optional[dict],dynamic_callback_params: StandardCallbackDynamicParams,prompt_label: Optional[str] = None,+ prompt_version: Optional[int] = None,) -> PromptManagementClient:raise NotImplementedError("Custom prompt management does not support compile prompt helper"diff --git a/litellm/integrations/humanloop.py b/litellm/integrations/humanloop.pyindex c62ab1110ff..9f43d806266 100644--- a/litellm/integrations/humanloop.py+++ b/litellm/integrations/humanloop.py@@ -156,7 +156,12 @@ class HumanloopLogger(CustomLogger):prompt_variables: Optional[dict],dynamic_callback_params: StandardCallbackDynamicParams,prompt_label: Optional[str] = None,- ) -> Tuple[str, List[AllMessageValues], dict,]:+ prompt_version: Optional[int] = None,+ ) -> Tuple[+ str,+ List[AllMessageValues],+ dict,+ ]:humanloop_api_key = dynamic_callback_params.get("humanloop_api_key") or get_secret_str("HUMANLOOP_API_KEY")diff --git a/litellm/integrations/langfuse/langfuse_otel.py b/litellm/integrations/langfuse/langfuse_otel.pyindex 6d7f927c3ef..7fc222ff6c6 100644--- a/litellm/integrations/langfuse/langfuse_otel.py+++ b/litellm/integrations/langfuse/langfuse_otel.py@@ -1,6 +1,7 @@import base64import osfrom typing import TYPE_CHECKING, Any, Union+from urllib.parse import quotefrom litellm._logging import verbose_loggerfrom litellm.integrations.arize import _utils@@ -9,10 +10,11 @@ from litellm.types.integrations.langfuse_otel import LangfuseOtelConfigif TYPE_CHECKING:from opentelemetry.trace import Span as _Span+ from litellm.integrations.opentelemetry import (+ OpenTelemetryConfig as _OpenTelemetryConfig,+ )from litellm.types.integrations.arize import Protocol as _Protocol- from litellm.integrations.opentelemetry import OpenTelemetryConfig as _OpenTelemetryConfig-Protocol = _ProtocolOpenTelemetryConfig = _OpenTelemetryConfigSpan = Union[_Span, Any]@@ -54,7 +56,7 @@ class LangfuseOtelLogger:"""public_key = os.environ.get("LANGFUSE_PUBLIC_KEY", None)secret_key = os.environ.get("LANGFUSE_SECRET_KEY", None)-+if not public_key or not secret_key:raise ValueError("LANGFUSE_PUBLIC_KEY and LANGFUSE_SECRET_KEY must be set for Langfuse OpenTelemetry integration."@@ -62,7 +64,7 @@ class LangfuseOtelLogger:# Determine endpoint - default to US cloudlangfuse_host = os.environ.get("LANGFUSE_HOST", None)-+if langfuse_host:# If LANGFUSE_HOST is provided, construct OTEL endpoint from itif not langfuse_host.startswith("http"):@@ -77,13 +79,13 @@ class LangfuseOtelLogger:# Create Basic Auth headerauth_string = f"{public_key}:{secret_key}"auth_header = base64.b64encode(auth_string.encode()).decode()- otlp_auth_headers = f"Authorization=Basic {auth_header}"+ # URL encode the entire header value as required by OpenTelemetry specification+ otlp_auth_headers = f"Authorization={quote(f'Basic {auth_header}')}"# Set standard OTEL environment variablesos.environ["OTEL_EXPORTER_OTLP_ENDPOINT"] = endpointos.environ["OTEL_EXPORTER_OTLP_HEADERS"] = otlp_auth_headersreturn LangfuseOtelConfig(- otlp_auth_headers=otlp_auth_headers,- protocol="otlp_http"- )\ No newline at end of file+ otlp_auth_headers=otlp_auth_headers, protocol="otlp_http"+ )diff --git a/litellm/integrations/langfuse/langfuse_prompt_management.py b/litellm/integrations/langfuse/langfuse_prompt_management.pyindex 8fe9cb63dea..58698ef35a5 100644--- a/litellm/integrations/langfuse/langfuse_prompt_management.py+++ b/litellm/integrations/langfuse/langfuse_prompt_management.py@@ -134,8 +134,14 @@ class LangfusePromptManagement(LangFuseLogger, PromptManagementBase, CustomLoggelangfuse_prompt_id: str,langfuse_client: LangfuseClass,prompt_label: Optional[str] = None,+ prompt_version: Optional[int] = None,) -> PROMPT_CLIENT:- return langfuse_client.get_prompt(langfuse_prompt_id, label=prompt_label)++ prompt_client = langfuse_client.get_prompt(+ langfuse_prompt_id, label=prompt_label, version=prompt_version+ )++ return prompt_clientdef _compile_prompt(self,@@ -180,7 +186,12 @@ class LangfusePromptManagement(LangFuseLogger, PromptManagementBase, CustomLoggelitellm_logging_obj: LiteLLMLoggingObj,tools: Optional[List[Dict]] = None,prompt_label: Optional[str] = None,- ) -> Tuple[str, List[AllMessageValues], dict,]:+ prompt_version: Optional[int] = None,+ ) -> Tuple[+ str,+ List[AllMessageValues],+ dict,+ ]:return self.get_chat_completion_prompt(model,messages,@@ -189,6 +200,7 @@ class LangfusePromptManagement(LangFuseLogger, PromptManagementBase, CustomLoggeprompt_variables,dynamic_callback_params,prompt_label=prompt_label,+ prompt_version=prompt_version,)def should_run_prompt_management(@@ -203,7 +215,8 @@ class LangfusePromptManagement(LangFuseLogger, PromptManagementBase, CustomLoggelangfuse_host=dynamic_callback_params.get("langfuse_host"),)langfuse_prompt_client = self._get_prompt_from_id(- langfuse_prompt_id=prompt_id, langfuse_client=langfuse_client+ langfuse_prompt_id=prompt_id,+ langfuse_client=langfuse_client,)return langfuse_prompt_client is not None@@ -213,6 +226,7 @@ class LangfusePromptManagement(LangFuseLogger, PromptManagementBase, CustomLoggeprompt_variables: Optional[dict],dynamic_callback_params: StandardCallbackDynamicParams,prompt_label: Optional[str] = None,+ prompt_version: Optional[int] = None,) -> PromptManagementClient:langfuse_client = langfuse_client_init(langfuse_public_key=dynamic_callback_params.get("langfuse_public_key"),@@ -224,6 +238,7 @@ class LangfusePromptManagement(LangFuseLogger, PromptManagementBase, CustomLoggelangfuse_prompt_id=prompt_id,langfuse_client=langfuse_client,prompt_label=prompt_label,+ prompt_version=prompt_version,)## SET PROMPTdiff --git a/litellm/integrations/prompt_management_base.py b/litellm/integrations/prompt_management_base.pyindex c9e7adbccbd..4a8bcd2e249 100644--- a/litellm/integrations/prompt_management_base.py+++ b/litellm/integrations/prompt_management_base.py@@ -34,6 +34,7 @@ class PromptManagementBase(ABC):prompt_variables: Optional[dict],dynamic_callback_params: StandardCallbackDynamicParams,prompt_label: Optional[str] = None,+ prompt_version: Optional[int] = None,) -> PromptManagementClient:pass@@ -51,12 +52,14 @@ class PromptManagementBase(ABC):client_messages: List[AllMessageValues],dynamic_callback_params: StandardCallbackDynamicParams,prompt_label: Optional[str] = None,+ prompt_version: Optional[int] = None,) -> PromptManagementClient:compiled_prompt_client = self._compile_prompt_helper(prompt_id=prompt_id,prompt_variables=prompt_variables,dynamic_callback_params=dynamic_callback_params,prompt_label=prompt_label,+ prompt_version=prompt_version,)try:@@ -86,6 +89,7 @@ class PromptManagementBase(ABC):prompt_variables: Optional[dict],dynamic_callback_params: StandardCallbackDynamicParams,prompt_label: Optional[str] = None,+ prompt_version: Optional[int] = None,) -> Tuple[str, List[AllMessageValues], dict]:if prompt_id is None:raise ValueError("prompt_id is required for Prompt Management Base class")@@ -100,6 +104,7 @@ class PromptManagementBase(ABC):client_messages=messages,dynamic_callback_params=dynamic_callback_params,prompt_label=prompt_label,+ prompt_version=prompt_version,)completed_messages = prompt_template["completed_messages"] or messagesdiff --git a/litellm/integrations/vector_store_integrations/bedrock_vector_store.py b/litellm/integrations/vector_store_integrations/bedrock_vector_store.pyindex a00acefb6a3..d3ba3a8ebd6 100644--- a/litellm/integrations/vector_store_integrations/bedrock_vector_store.py+++ b/litellm/integrations/vector_store_integrations/bedrock_vector_store.py@@ -77,6 +77,7 @@ class BedrockVectorStore(BaseVectorStore, BaseAWSLLM):litellm_logging_obj: LiteLLMLoggingObj,tools: Optional[List[Dict]] = None,prompt_label: Optional[str] = None,+ prompt_version: Optional[int] = None,) -> Tuple[str, List[AllMessageValues], dict]:"""Retrieves the context from the Bedrock Knowledge Base and appends it to the messages.@@ -129,9 +130,9 @@ class BedrockVectorStore(BaseVectorStore, BaseAWSLLM):))- litellm_logging_obj.model_call_details[- "vector_store_request_metadata"- ] = vector_store_request_metadata+ litellm_logging_obj.model_call_details["vector_store_request_metadata"] = (+ vector_store_request_metadata+ )return model, messages, non_default_params@@ -143,9 +144,9 @@ class BedrockVectorStore(BaseVectorStore, BaseAWSLLM):"""Transform a BedrockKBResponse to a VectorStoreSearchResponse"""- retrieval_results: Optional[- List[BedrockKBRetrievalResult]- ] = bedrock_kb_response.get("retrievalResults", None)+ retrieval_results: Optional[List[BedrockKBRetrievalResult]] = (+ bedrock_kb_response.get("retrievalResults", None)+ )vector_store_search_response: VectorStoreSearchResponse = (VectorStoreSearchResponse(search_query=query, data=[]))diff --git a/litellm/integrations/vector_stores/bedrock_vector_store.py b/litellm/integrations/vector_stores/bedrock_vector_store.pyindex a00acefb6a3..d3ba3a8ebd6 100644--- a/litellm/integrations/vector_stores/bedrock_vector_store.py+++ b/litellm/integrations/vector_stores/bedrock_vector_store.py@@ -77,6 +77,7 @@ class BedrockVectorStore(BaseVectorStore, BaseAWSLLM):litellm_logging_obj: LiteLLMLoggingObj,tools: Optional[List[Dict]] = None,prompt_label: Optional[str] = None,+ prompt_version: Optional[int] = None,) -> Tuple[str, List[AllMessageValues], dict]:"""Retrieves the context from the Bedrock Knowledge Base and appends it to the messages.@@ -129,9 +130,9 @@ class BedrockVectorStore(BaseVectorStore, BaseAWSLLM):))- litellm_logging_obj.model_call_details[- "vector_store_request_metadata"- ] = vector_store_request_metadata+ litellm_logging_obj.model_call_details["vector_store_request_metadata"] = (+ vector_store_request_metadata+ )return model, messages, non_default_params@@ -143,9 +144,9 @@ class BedrockVectorStore(BaseVectorStore, BaseAWSLLM):"""Transform a BedrockKBResponse to a VectorStoreSearchResponse"""- retrieval_results: Optional[- List[BedrockKBRetrievalResult]- ] = bedrock_kb_response.get("retrievalResults", None)+ retrieval_results: Optional[List[BedrockKBRetrievalResult]] = (+ bedrock_kb_response.get("retrievalResults", None)+ )vector_store_search_response: VectorStoreSearchResponse = (VectorStoreSearchResponse(search_query=query, data=[]))diff --git a/litellm/litellm_core_utils/initialize_dynamic_callback_params.py b/litellm/litellm_core_utils/initialize_dynamic_callback_params.pyindex e5a19e7bddc..c425319b4d4 100644--- a/litellm/litellm_core_utils/initialize_dynamic_callback_params.py+++ b/litellm/litellm_core_utils/initialize_dynamic_callback_params.py@@ -18,6 +18,7 @@ def initialize_standard_callback_dynamic_params(_supported_callback_params = (StandardCallbackDynamicParams.__annotations__.keys())+for param in _supported_callback_params:if param in kwargs:_param_value = kwargs.pop(param)diff --git a/litellm/litellm_core_utils/litellm_logging.py b/litellm/litellm_core_utils/litellm_logging.pyindex f7be8b1bb5c..9ff7903540e 100644--- a/litellm/litellm_core_utils/litellm_logging.py+++ b/litellm/litellm_core_utils/litellm_logging.py@@ -435,6 +435,7 @@ class Logging(LiteLLMLoggingBaseClass):checks if langfuse_secret_key, gcs_bucket_name in kwargs and sets the corresponding attributes in StandardCallbackDynamicParams"""+return _initialize_standard_callback_dynamic_params(kwargs)def initialize_standard_built_in_tools_params(@@ -556,6 +557,7 @@ class Logging(LiteLLMLoggingBaseClass):prompt_variables: Optional[dict],prompt_management_logger: Optional[CustomLogger] = None,prompt_label: Optional[str] = None,+ prompt_version: Optional[int] = None,) -> Tuple[str, List[AllMessageValues], dict]:custom_logger = (prompt_management_logger@@ -577,6 +579,7 @@ class Logging(LiteLLMLoggingBaseClass):prompt_variables=prompt_variables,dynamic_callback_params=self.standard_callback_dynamic_params,prompt_label=prompt_label,+ prompt_version=prompt_version,)self.messages = messagesreturn model, messages, non_default_params@@ -591,6 +594,7 @@ class Logging(LiteLLMLoggingBaseClass):prompt_management_logger: Optional[CustomLogger] = None,tools: Optional[List[Dict]] = None,prompt_label: Optional[str] = None,+ prompt_version: Optional[int] = None,) -> Tuple[str, List[AllMessageValues], dict]:custom_logger = (prompt_management_logger@@ -614,6 +618,7 @@ class Logging(LiteLLMLoggingBaseClass):litellm_logging_obj=self,tools=tools,prompt_label=prompt_label,+ prompt_version=prompt_version,)self.messages = messagesreturn model, messages, non_default_params@@ -2953,8 +2958,6 @@ def set_callbacks(callback_list, function_id=None): # noqa: PLR0915import sentry_sdkfrom sentry_sdk.scrubber import EventScrubber--sentry_sdk_instance = sentry_sdksentry_trace_rate = (os.environ.get("SENTRY_API_TRACE_RATE")@@ -2974,8 +2977,7 @@ def set_callbacks(callback_list, function_id=None): # noqa: PLR0915),send_default_pii=False, # Prevent sending Personal Identifiable Informationevent_scrubber=EventScrubber(- denylist=SENTRY_DENYLIST,- pii_denylist=SENTRY_PII_DENYLIST+ denylist=SENTRY_DENYLIST, pii_denylist=SENTRY_PII_DENYLIST),)capture_exception = sentry_sdk_instance.capture_exception@@ -3033,6 +3035,7 @@ def set_callbacks(callback_list, function_id=None): # noqa: PLR0915s3Logger = S3Logger()elif callback == "wandb":from litellm.integrations.weights_biases import WeightsBiasesLogger+weightsBiasesLogger = WeightsBiasesLogger()elif callback == "logfire":logfireLogger = LogfireLogger()@@ -3087,6 +3090,7 @@ def _init_custom_logger_compatible_class( # noqa: PLR0915return _openmeter_logger # type: ignoreelif logging_integration == "braintrust":from litellm.integrations.braintrust_logging import BraintrustLogger+for callback in _in_memory_loggers:if isinstance(callback, BraintrustLogger):return callback # type: ignore@@ -3453,6 +3457,7 @@ def get_custom_logger_compatible_class( # noqa: PLR0915return callbackelif logging_integration == "braintrust":from litellm.integrations.braintrust_logging import BraintrustLogger+for callback in _in_memory_loggers:if isinstance(callback, BraintrustLogger):return callbackdiff --git a/litellm/main.py b/litellm/main.pyindex da6db8e8358..5d0662060d6 100644--- a/litellm/main.py+++ b/litellm/main.py@@ -438,6 +438,7 @@ async def acompletion(prompt_variables=kwargs.get("prompt_variables", None),tools=tools,prompt_label=kwargs.get("prompt_label", None),+ prompt_version=kwargs.get("prompt_version", None),)########################################################## if the chat completion logging hook removed all tools,@@ -1062,6 +1063,7 @@ def completion( # type: ignore # noqa: PLR0915prompt_id=prompt_id,prompt_variables=prompt_variables,prompt_label=kwargs.get("prompt_label", None),+ prompt_version=kwargs.get("prompt_version", None),)try:@@ -1950,7 +1952,7 @@ def completion( # type: ignore # noqa: PLR0915or get_secret("MISTRAL_API_BASE")or "https://api.mistral.ai/v1")-+response = base_llm_http_handler.completion(model=model,messages=messages,@@ -2615,9 +2617,7 @@ def completion( # type: ignore # noqa: PLR0915api_base = api_base or litellm.api_base or get_secret("VERTEXAI_API_BASE")new_params = deepcopy(optional_params)- if (- vertex_partner_models_chat_completion.is_vertex_partner_model(model)- ):+ if vertex_partner_models_chat_completion.is_vertex_partner_model(model):model_response = vertex_partner_models_chat_completion.completion(model=model,messages=messages,diff --git a/litellm/proxy/_experimental/out/onboarding.html b/litellm/proxy/_experimental/out/onboarding.htmldeleted file mode 100644index be3a9891975..00000000000--- a/litellm/proxy/_experimental/out/onboarding.html+++ /dev/null@@ -1 +0,0 @@-<!DOCTYPE html><html id="__next_error__"><head><meta charSet="utf-8"/><meta name="viewport" content="width=device-width, initial-scale=1"/><link rel="preload" as="script" fetchPriority="low" href="/litellm-asset-prefix/_next/static/chunks/webpack-a426aae3231a8df1.js"/><script src="/litellm-asset-prefix/_next/static/chunks/fd9d1056-205af899b895cbac.js" async=""></script><script src="/litellm-asset-prefix/_next/static/chunks/117-a0da667066d322b6.js" async=""></script><script src="/litellm-asset-prefix/_next/static/chunks/main-app-475d6efe4080647d.js" async=""></script><title>LiteLLM Dashboard</title><meta name="description" content="LiteLLM Proxy Admin UI"/><link rel="icon" href="/favicon.ico" type="image/x-icon" sizes="16x16"/><link rel="icon" href="./favicon.ico"/><meta name="next-size-adjust"/><script src="/litellm-asset-prefix/_next/static/chunks/polyfills-42372ed130431b0a.js" noModule=""></script></head><body><script src="/litellm-asset-prefix/_next/static/chunks/webpack-a426aae3231a8df1.js" async=""></script><script>(self.__next_f=self.__next_f||[]).push([0]);self.__next_f.push([2,null])</script><script>self.__next_f.push([1,"1:HL[\"/litellm-asset-prefix/_next/static/media/e4af272ccee01ff0-s.p.woff2\",\"font\",{\"crossOrigin\":\"\",\"type\":\"font/woff2\"}]\n2:HL[\"/litellm-asset-prefix/_next/static/css/31b7f215e119031e.css\",\"style\"]\n3:HL[\"/litellm-asset-prefix/_next/static/css/ec568c98dd91ff9a.css\",\"style\"]\n"])</script><script>self.__next_f.push([1,"4:I[12846,[],\"\"]\n6:I[19107,[],\"ClientPageRoot\"]\n7:I[12011,[\"665\",\"static/chunks/3014691f-b7b79b78e27792f3.js\",\"402\",\"static/chunks/402-239a4ed70dc393da.js\",\"899\",\"static/chunks/899-368210dea705c35d.js\",\"250\",\"static/chunks/250-79aed9159b64ca09.js\",\"461\",\"static/chunks/app/onboarding/page-9659af55efbf16f8.js\"],\"default\",1]\n8:I[4707,[],\"\"]\n9:I[36423,[],\"\"]\nb:I[61060,[],\"\"]\nc:[]\n"])</script><script>self.__next_f.push([1,"0:[\"$\",\"$L4\",null,{\"buildId\":\"SLmuq1lkVA1WSIG63pN6h\",\"assetPrefix\":\"/litellm-asset-prefix\",\"urlParts\":[\"\",\"onboarding\"],\"initialTree\":[\"\",{\"children\":[\"onboarding\",{\"children\":[\"__PAGE__\",{}]}]},\"$undefined\",\"$undefined\",true],\"initialSeedData\":[\"\",{\"children\":[\"onboarding\",{\"children\":[\"__PAGE__\",{},[[\"$L5\",[\"$\",\"$L6\",null,{\"props\":{\"params\":{},\"searchParams\":{}},\"Component\":\"$7\"}],null],null],null]},[null,[\"$\",\"$L8\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\",\"onboarding\",\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L9\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":\"$undefined\",\"notFoundStyles\":\"$undefined\"}]],null]},[[[[\"$\",\"link\",\"0\",{\"rel\":\"stylesheet\",\"href\":\"/litellm-asset-prefix/_next/static/css/31b7f215e119031e.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}],[\"$\",\"link\",\"1\",{\"rel\":\"stylesheet\",\"href\":\"/litellm-asset-prefix/_next/static/css/ec568c98dd91ff9a.css\",\"precedence\":\"next\",\"crossOrigin\":\"$undefined\"}]],[\"$\",\"html\",null,{\"lang\":\"en\",\"children\":[\"$\",\"body\",null,{\"className\":\"__className_b0dd8a\",\"children\":[\"$\",\"$L8\",null,{\"parallelRouterKey\":\"children\",\"segmentPath\":[\"children\"],\"error\":\"$undefined\",\"errorStyles\":\"$undefined\",\"errorScripts\":\"$undefined\",\"template\":[\"$\",\"$L9\",null,{}],\"templateStyles\":\"$undefined\",\"templateScripts\":\"$undefined\",\"notFound\":[[\"$\",\"title\",null,{\"children\":\"404: This page could not be found.\"}],[\"$\",\"div\",null,{\"style\":{\"fontFamily\":\"system-ui,\\\"Segoe UI\\\",Roboto,Helvetica,Arial,sans-serif,\\\"Apple Color Emoji\\\",\\\"Segoe UI Emoji\\\"\",\"height\":\"100vh\",\"textAlign\":\"center\",\"display\":\"flex\",\"flexDirection\":\"column\",\"alignItems\":\"center\",\"justifyContent\":\"center\"},\"children\":[\"$\",\"div\",null,{\"children\":[[\"$\",\"style\",null,{\"dangerouslySetInnerHTML\":{\"__html\":\"body{color:#000;background:#fff;margin:0}.next-error-h1{border-right:1px solid rgba(0,0,0,.3)}@media (prefers-color-scheme:dark){body{color:#fff;background:#000}.next-error-h1{border-right:1px solid rgba(255,255,255,.3)}}\"}}],[\"$\",\"h1\",null,{\"className\":\"next-error-h1\",\"style\":{\"display\":\"inline-block\",\"margin\":\"0 20px 0 0\",\"padding\":\"0 23px 0 0\",\"fontSize\":24,\"fontWeight\":500,\"verticalAlign\":\"top\",\"lineHeight\":\"49px\"},\"children\":\"404\"}],[\"$\",\"div\",null,{\"style\":{\"display\":\"inline-block\"},\"children\":[\"$\",\"h2\",null,{\"style\":{\"fontSize\":14,\"fontWeight\":400,\"lineHeight\":\"49px\",\"margin\":0},\"children\":\"This page could not be found.\"}]}]]}]}]],\"notFoundStyles\":[]}]}]}]],null],null],\"couldBeIntercepted\":false,\"initialHead\":[null,\"$La\"],\"globalErrorComponent\":\"$b\",\"missingSlots\":\"$Wc\"}]\n"])</script><script>self.__next_f.push([1,"a:[[\"$\",\"meta\",\"0\",{\"name\":\"viewport\",\"content\":\"width=device-width, initial-scale=1\"}],[\"$\",\"meta\",\"1\",{\"charSet\":\"utf-8\"}],[\"$\",\"title\",\"2\",{\"children\":\"LiteLLM Dashboard\"}],[\"$\",\"meta\",\"3\",{\"name\":\"description\",\"content\":\"LiteLLM Proxy Admin UI\"}],[\"$\",\"link\",\"4\",{\"rel\":\"icon\",\"href\":\"/favicon.ico\",\"type\":\"image/x-icon\",\"sizes\":\"16x16\"}],[\"$\",\"link\",\"5\",{\"rel\":\"icon\",\"href\":\"./favicon.ico\"}],[\"$\",\"meta\",\"6\",{\"name\":\"next-size-adjust\"}]]\n5:null\n"])</script></body></html>\ No newline at end of filediff --git a/litellm/proxy/_new_secret_config.yaml b/litellm/proxy/_new_secret_config.yamlindex 8be231a1fe5..afaac02c081 100644--- a/litellm/proxy/_new_secret_config.yaml+++ b/litellm/proxy/_new_secret_config.yaml@@ -3,11 +3,11 @@ model_list:litellm_params:model: openai/gpt-3.5-turboapi_key: os.environ/OPENAI_API_KEY--guardrails:- - guardrail_name: azure-prompt-shield+ - model_name: langfuse-modellitellm_params:- guardrail: azure/prompt_shield- mode: pre_call # "During_call" is also available- api_key: os.environ/AZURE_GUARDRAIL_API_KEY- api_base: os.environ/AZURE_GUARDRAIL_API_BASE\ No newline at end of file+ model: langfuse/langfuse-model+ prompt_id: test-chat-prompt+ prompt_version: 4++litellm_settings:+ callbacks: ["langfuse_otel"]\ No newline at end of filediff --git a/litellm/proxy/custom_prompt_management.py b/litellm/proxy/custom_prompt_management.pyindex 8cf20da5e92..cae5890b6cc 100644--- a/litellm/proxy/custom_prompt_management.py+++ b/litellm/proxy/custom_prompt_management.py@@ -16,6 +16,7 @@ class X42PromptManagement(CustomPromptManagement):prompt_variables: Optional[dict],dynamic_callback_params: StandardCallbackDynamicParams,prompt_label: Optional[str] = None,+ prompt_version: Optional[int] = None,) -> Tuple[str, List[AllMessageValues], dict]:"""Returns:diff --git a/litellm/router.py b/litellm/router.pyindex dc12b924ff7..4ed86580588 100644--- a/litellm/router.py+++ b/litellm/router.py@@ -1735,6 +1735,7 @@ class Router:kwargs: Dict[str, Any],):litellm_logging_object = kwargs.get("litellm_logging_obj", None)+if litellm_logging_object is None:litellm_logging_object, kwargs = function_setup(**{@@ -1770,6 +1771,10 @@ class Router:"litellm_params"].get("prompt_label", None)+ prompt_version = kwargs.get(+ "prompt_version", None+ ) or prompt_management_deployment["litellm_params"].get("prompt_version", None)+if prompt_id is None or not isinstance(prompt_id, str):raise ValueError(f"Prompt ID is not set or not a string. Got={prompt_id}, type={type(prompt_id)}"@@ -1790,6 +1795,7 @@ class Router:prompt_id=prompt_id,prompt_variables=prompt_variables,prompt_label=prompt_label,+ prompt_version=prompt_version,)kwargs = {**data, **kwargs, **optional_params}diff --git a/litellm/types/utils.py b/litellm/types/utils.pyindex b9d24d94551..3f5ea0785c3 100644--- a/litellm/types/utils.py+++ b/litellm/types/utils.py@@ -2072,6 +2072,9 @@ class StandardCallbackDynamicParams(TypedDict, total=False):langfuse_secret_key: Optional[str]langfuse_host: Optional[str]+ # Langfuse prompt version+ langfuse_prompt_version: Optional[int]+# GCS dynamic paramsgcs_bucket_name: Optional[str]gcs_path_service_account: Optional[str]@@ -2112,6 +2115,7 @@ all_litellm_params = ["prompt_id","provider_specific_header","prompt_variables",+ "prompt_version","api_base","force_timeout","logger_fn",diff --git a/tests/test_litellm/integrations/langfuse/test_langfuse_prompt_management.py b/tests/test_litellm/integrations/langfuse/test_langfuse_prompt_management.pynew file mode 100644index 00000000000..7a5b8bfb1cb--- /dev/null+++ b/tests/test_litellm/integrations/langfuse/test_langfuse_prompt_management.py@@ -0,0 +1,32 @@+import os+from unittest.mock import patch++from litellm.integrations.langfuse.langfuse_prompt_management import (+ LangfusePromptManagement,+)+++class TestLangfusePromptManagement:+ def test_get_prompt_from_id(self):+ langfuse_prompt_management = LangfusePromptManagement()+ with patch.object(+ langfuse_prompt_management, "should_run_prompt_management"+ ) as mock_should_run_prompt_management, patch.object(+ langfuse_prompt_management, "_get_prompt_from_id"+ ) as mock_get_prompt_from_id:+ mock_should_run_prompt_management.return_value = True+ chat_completion_prompt = (+ langfuse_prompt_management.get_chat_completion_prompt(+ model="langfuse/langfuse-model",+ messages=[{"role": "user", "content": "Hello, how are you?"}],+ non_default_params={},+ prompt_id="test-chat-prompt",+ prompt_variables={},+ dynamic_callback_params={},+ prompt_version=4,+ )+ )++ mock_get_prompt_from_id.assert_called_once()+ print(mock_get_prompt_from_id.call_args.kwargs)+ assert mock_get_prompt_from_id.call_args.kwargs["prompt_version"] == 4diff --git a/tests/test_litellm/integrations/test_custom_prompt_management.py b/tests/test_litellm/integrations/test_custom_prompt_management.pyindex f5855abf71e..f01462070fc 100644--- a/tests/test_litellm/integrations/test_custom_prompt_management.py+++ b/tests/test_litellm/integrations/test_custom_prompt_management.py@@ -33,7 +33,8 @@ class TestCustomPromptManagement(CustomPromptManagement):prompt_id: Optional[str],prompt_variables: Optional[dict],dynamic_callback_params: StandardCallbackDynamicParams,- prompt_label: Optional[str],+ prompt_label: Optional[str] = None,+ prompt_version: Optional[int] = None,) -> Tuple[str, List[AllMessageValues], dict]:print("TestCustomPromptManagement: running get_chat_completion_prompt for prompt_id: ",