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
Integrate CompactifAI provider into LiteLLM core
Tim Elfrink9402dc35aa78
diff --git a/litellm/__init__.py b/litellm/__init__.pyindex f6be2bc6f00..9d00d14086f 100644--- a/litellm/__init__.py+++ b/litellm/__init__.py@@ -1013,6 +1013,7 @@ from .llms.openai_like.chat.handler import OpenAILikeChatConfigfrom .llms.aiohttp_openai.chat.transformation import AiohttpOpenAIChatConfigfrom .llms.galadriel.chat.transformation import GaladrielChatConfigfrom .llms.github.chat.transformation import GithubChatConfig+from .llms.compactifai.chat.transformation import CompactifAIChatConfigfrom .llms.empower.chat.transformation import EmpowerChatConfigfrom .llms.huggingface.chat.transformation import HuggingFaceChatConfigfrom .llms.huggingface.embedding.transformation import HuggingFaceEmbeddingConfigdiff --git a/litellm/litellm_core_utils/get_llm_provider_logic.py b/litellm/litellm_core_utils/get_llm_provider_logic.pyindex d5009fb0ca6..5aa29e1250e 100644--- a/litellm/litellm_core_utils/get_llm_provider_logic.py+++ b/litellm/litellm_core_utils/get_llm_provider_logic.py@@ -372,6 +372,8 @@ def get_llm_provider( # noqa: PLR0915custom_llm_provider = "cometapi"elif model.startswith("oci/"):custom_llm_provider = "oci"+ elif model.startswith("compactifai/"):+ custom_llm_provider = "compactifai"if not custom_llm_provider:if litellm.suppress_debug_info is False:print() # noqadiff --git a/litellm/main.py b/litellm/main.pyindex 6c81d3eded9..fa52771028b 100644--- a/litellm/main.py+++ b/litellm/main.py@@ -2547,6 +2547,36 @@ def completion( # type: ignore # noqa: PLR0915encoding=encoding,stream=stream,)+ elif custom_llm_provider == "compactifai":+ api_key = (+ api_key+ or get_secret_str("COMPACTIFAI_API_KEY")+ or litellm.api_key+ )++ api_base = (+ api_base+ or "https://api.compactif.ai/v1"+ )++ ## COMPLETION CALL+ response = base_llm_http_handler.completion(+ model=model,+ messages=messages,+ headers=headers,+ model_response=model_response,+ api_key=api_key,+ api_base=api_base,+ acompletion=acompletion,+ logging_obj=logging,+ optional_params=optional_params,+ litellm_params=litellm_params,+ timeout=timeout,+ client=client,+ custom_llm_provider=custom_llm_provider,+ encoding=encoding,+ stream=stream,+ )elif custom_llm_provider == "oobabooga":custom_llm_provider = "oobabooga"model_response = oobabooga.completion(diff --git a/litellm/types/utils.py b/litellm/types/utils.pyindex 7f6ab8e7d08..d12afb523bb 100644--- a/litellm/types/utils.py+++ b/litellm/types/utils.py@@ -2327,6 +2327,7 @@ class LlmProviders(str, Enum):DATABRICKS = "databricks"EMPOWER = "empower"GITHUB = "github"+ COMPACTIFAI = "compactifai"CUSTOM = "custom"LITELLM_PROXY = "litellm_proxy"HOSTED_VLLM = "hosted_vllm"diff --git a/litellm/utils.py b/litellm/utils.pyindex 0d2fe5d4d64..7236e0c6afe 100644--- a/litellm/utils.py+++ b/litellm/utils.py@@ -6931,6 +6931,8 @@ class ProviderConfigManager:return litellm.EmpowerChatConfig()elif litellm.LlmProviders.GITHUB == provider:return litellm.GithubChatConfig()+ elif litellm.LlmProviders.COMPACTIFAI == provider:+ return litellm.CompactifAIChatConfig()elif litellm.LlmProviders.GITHUB_COPILOT == provider:return litellm.GithubCopilotConfig()elif (