Skip to content

feat: add LiteLLM as AI gateway provider#133

Open
RheagalFire wants to merge 1 commit into
Mirix-AI:mainfrom
RheagalFire:feat/add-litellm-provider
Open

feat: add LiteLLM as AI gateway provider#133
RheagalFire wants to merge 1 commit into
Mirix-AI:mainfrom
RheagalFire:feat/add-litellm-provider

Conversation

@RheagalFire
Copy link
Copy Markdown

@RheagalFire RheagalFire commented May 28, 2026

Summary

Adds LiteLLM as a new LLM provider, giving MIRIX users access to 100+ LLM providers (OpenAI, Anthropic, Azure, Bedrock, Vertex AI, Groq, Ollama, etc.) through a single unified interface via the LiteLLM Python SDK.

Changes

  • mirix/llm_api/litellm_client.py -- new LiteLLMClient extending LLMClientBase, uses litellm.acompletion() with drop_params=True
  • mirix/llm_api/llm_client.py -- added "litellm" case to factory
  • mirix/schemas/llm_config.py -- added "litellm" to model_endpoint_type Literal
  • pyproject.toml -- added litellm>=1.80.0,<1.87.0 as optional dependency

Tests

Live E2E against Azure Foundry (Anthropic Claude Sonnet 4.6):

config = LLMConfig(
    model='anthropic/claude-sonnet-4-6',
    model_endpoint_type='litellm',
    model_endpoint='https://azure-endpoint.services.ai.azure.com/anthropic',
    context_window=200000,
    api_key='...',
)
client = LLMClient.create(config)
msgs = [Message(role='user', content=[TextContent(type='text', text='What is 2+2? Reply with just the number.')])]
resp = await client.send_llm_request(msgs)
Client type: LiteLLMClient
Response: 4
Model: claude-sonnet-4-6
Tokens: 20 in, 5 out

Lint: make format passes clean.

Example usage

from mirix.schemas.llm_config import LLMConfig

# Use any provider supported by LiteLLM (100+)
# Model format: provider/model-name
config = LLMConfig(
    model="anthropic/claude-haiku-4-5",
    model_endpoint_type="litellm",
    context_window=200000,
)

# Provider API keys are read from environment variables
# e.g. ANTHROPIC_API_KEY, OPENAI_API_KEY, etc.
# Or pass api_key directly in the config

Risk / Compatibility

  • Additive only -- no existing providers modified
  • litellm is an optional dependency (pip install mirix[litellm])
  • Lazy-imported inside request() so base install is unaffected

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 28, 2026

CLA assistant check
All committers have signed the CLA.

@RheagalFire
Copy link
Copy Markdown
Author

cc @LiaoJianhe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants