Skip to content

LiteLLM

Use 100+ LLM providers through a single unified interface via LiteLLM.

Install

bash
pip install --extra-index-url https://core-packages.elsai.ai/root/elsai-model/ elsai-model

Basic usage

python
from elsai import Agent
from elsai_model.litellm import LiteLLMConnector

# Any LiteLLM-supported model name
model = LiteLLMConnector(model_name="gpt-4o")
agent = Agent(model=model)
result = agent("Hello!")

Examples

python
import os
from elsai_model.litellm import LiteLLMConnector

# OpenAI
model = LiteLLMConnector(model_name="gpt-4o")

# Anthropic via LiteLLM
model = LiteLLMConnector(model_name="anthropic/claude-3-5-sonnet")

# Cohere
model = LiteLLMConnector(model_name="cohere/command-r-plus")

# Vertex AI
model = LiteLLMConnector(model_name="vertex_ai/gemini-1.5-pro")

# Azure OpenAI (Configure credentials via environment variables)
os.environ["AZURE_API_BASE"] = "https://YOUR_RESOURCE.openai.azure.com"
os.environ["AZURE_API_KEY"] = "your-key"
model = LiteLLMConnector(
    model_name="azure/gpt-4o",
)

Configuration

Set provider keys or api bases in your environment. LiteLLM dynamically loads these from standard env variables (e.g. OPENAI_API_KEY, ANTHROPIC_API_KEY):

python
from elsai_model.litellm import LiteLLMConnector

model = LiteLLMConnector(
    model_name="gpt-4o",
    temperature=0.5,
)

LiteLLM gives you access to providers including OpenAI, Anthropic, Cohere, Together AI, Replicate, Hugging Face, Azure, Vertex AI, and many more.

Copyright © 2026 Elsai Foundry.