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 langfuse prompt management on proxy (#7535)
Krish Dholakiaf6698e871fa8
diff --git a/litellm/main.py b/litellm/main.pyindex e35b68abf8a..157d2a78655 100644--- a/litellm/main.py+++ b/litellm/main.py@@ -435,74 +435,26 @@ async def acompletion(ctx = contextvars.copy_context()func_with_context = partial(ctx.run, func)+ init_response = await loop.run_in_executor(None, func_with_context)+ if isinstance(init_response, dict) or isinstance(+ init_response, ModelResponse+ ): ## CACHING SCENARIO+ if isinstance(init_response, dict):+ response = ModelResponse(**init_response)+ response = init_response+ elif asyncio.iscoroutine(init_response):+ response = await init_response+ else:+ response = init_response # type: ignore+if (- custom_llm_provider == "openai"- or custom_llm_provider == "azure"- or custom_llm_provider == "azure_text"- or custom_llm_provider == "custom_openai"- or custom_llm_provider == "anyscale"- or custom_llm_provider == "mistral"- or custom_llm_provider == "openrouter"- or custom_llm_provider == "deepinfra"- or custom_llm_provider == "perplexity"- or custom_llm_provider == "groq"- or custom_llm_provider == "nvidia_nim"- or custom_llm_provider == "cohere_chat"- or custom_llm_provider == "cohere"- or custom_llm_provider == "cerebras"- or custom_llm_provider == "sambanova"- or custom_llm_provider == "ai21_chat"- or custom_llm_provider == "ai21"- or custom_llm_provider == "volcengine"- or custom_llm_provider == "codestral"+ custom_llm_provider == "text-completion-openai"or custom_llm_provider == "text-completion-codestral"- or custom_llm_provider == "deepseek"- or custom_llm_provider == "text-completion-openai"- or custom_llm_provider == "huggingface"- or custom_llm_provider == "ollama"- or custom_llm_provider == "ollama_chat"- or custom_llm_provider == "replicate"- or custom_llm_provider == "vertex_ai"- or custom_llm_provider == "vertex_ai_beta"- or custom_llm_provider == "gemini"- or custom_llm_provider == "sagemaker"- or custom_llm_provider == "sagemaker_chat"- or custom_llm_provider == "anthropic"- or custom_llm_provider == "anthropic_text"- or custom_llm_provider == "predibase"- or custom_llm_provider == "bedrock"- or custom_llm_provider == "databricks"- or custom_llm_provider == "triton"- or custom_llm_provider == "clarifai"- or custom_llm_provider == "watsonx"- or custom_llm_provider == "cloudflare"- or custom_llm_provider == "aiohttp_openai"- or custom_llm_provider in litellm.openai_compatible_providers- or custom_llm_provider in litellm._custom_providers- ): # currently implemented aiohttp calls for just azure, openai, hf, ollama, vertex ai soon all.- init_response = await loop.run_in_executor(None, func_with_context)- if isinstance(init_response, dict) or isinstance(- init_response, ModelResponse- ): ## CACHING SCENARIO- if isinstance(init_response, dict):- response = ModelResponse(**init_response)- response = init_response- elif asyncio.iscoroutine(init_response):- response = await init_response- else:- response = init_response # type: ignore-- if (- custom_llm_provider == "text-completion-openai"- or custom_llm_provider == "text-completion-codestral"- ) and isinstance(response, TextCompletionResponse):- response = litellm.OpenAITextCompletionConfig().convert_to_chat_model_response_object(- response_object=response,- model_response_object=litellm.ModelResponse(),- )- else:- # Call the synchronous function using run_in_executor- response = await loop.run_in_executor(None, func_with_context) # type: ignore+ ) and isinstance(response, TextCompletionResponse):+ response = litellm.OpenAITextCompletionConfig().convert_to_chat_model_response_object(+ response_object=response,+ model_response_object=litellm.ModelResponse(),+ )if isinstance(response, CustomStreamWrapper):response.set_logging_event_loop(loop=loopdiff --git a/litellm/proxy/_new_secret_config.yaml b/litellm/proxy/_new_secret_config.yamlindex 35e27ada0d7..dc7bf9d62b3 100644--- a/litellm/proxy/_new_secret_config.yaml+++ b/litellm/proxy/_new_secret_config.yaml@@ -3,6 +3,13 @@ model_list:litellm_params:model: openai/gpt-3.5-turboapi_key: os.environ/OPENAI_API_KEY+ - model_name: chatbot_actions+ litellm_params:+ model: langfuse/azure/gpt-4o+ api_base: "os.environ/AZURE_API_BASE"+ api_key: "os.environ/AZURE_API_KEY"+ tpm: 1000000+ prompt_id: "jokes"litellm_settings:default_team_settings:diff --git a/litellm/types/utils.py b/litellm/types/utils.pyindex 623400ae455..d80b75f73a5 100644--- a/litellm/types/utils.py+++ b/litellm/types/utils.py@@ -1800,6 +1800,8 @@ class LlmProviders(str, Enum):INFINITY = "infinity"DEEPGRAM = "deepgram"AIOHTTP_OPENAI = "aiohttp_openai"+ LANGFUSE = "langfuse"+ HUMANLOOP = "humanloop"class LiteLLMLoggingBaseClass: