LiteLLM
by @ishaan-jaff
Call 100+ LLM providers through LiteLLM's unified API. Use when you need to call a different model than your primary (e.g., use GPT-4 for code review while running on Claude), compare outputs from multiple models, route to cheaper models for simple tasks, or access models your runtime doesn't natively support.
clawhub install litellmπ About This Skill
name: litellm description: Call 100+ LLM providers through LiteLLM's unified API. Use when you need to call a different model than your primary (e.g., use GPT-4 for code review while running on Claude), compare outputs from multiple models, route to cheaper models for simple tasks, or access models your runtime doesn't natively support.
LiteLLM - Multi-Model LLM Calls
Use LiteLLM when you need to call LLMs beyond your primary model.
When to Use
Quick Start
import litellmCall any model with unified API
response = litellm.completion(
model="gpt-4o",
messages=[{"role": "user", "content": "Explain this code"}]
)
print(response.choices[0].message.content)
Common Patterns
Compare Multiple Models
import litellmprompt = [{"role": "user", "content": "What's the best approach to X?"}]
models = ["gpt-4o", "claude-sonnet-4-20250514", "gemini/gemini-1.5-pro"]
for model in models:
resp = litellm.completion(model=model, messages=prompt)
print(f"{model}: {resp.choices[0].message.content[:200]}...")
Route by Task Type
import litellmdef smart_call(task_type: str, prompt: str) -> str:
model_map = {
"code": "gpt-4o", # Strong at code
"writing": "claude-sonnet-4-20250514", # Strong at prose
"simple": "gpt-4o-mini", # Cheap for simple tasks
"reasoning": "o1-preview", # Deep reasoning
}
model = model_map.get(task_type, "gpt-4o")
resp = litellm.completion(
model=model,
messages=[{"role": "user", "content": prompt}]
)
return resp.choices[0].message.content
Use LiteLLM Proxy (Recommended)
If a LiteLLM proxy is available, point to it for caching, rate limiting, and observability:
import litellmlitellm.api_base = "https://your-litellm-proxy.com"
litellm.api_key = "sk-your-key"
response = litellm.completion(
model="gpt-4o", # Proxy routes to configured provider
messages=[{"role": "user", "content": "Hello"}]
)
Environment Setup
Ensure litellm is installed and API keys are set:
pip install litellmSet provider keys (or configure in proxy)
export OPENAI_API_KEY="sk-..."
export ANTHROPIC_API_KEY="sk-..."
Model Reference
Common model identifiers:
gpt-4o, gpt-4o-mini, o1-preview, o1-miniclaude-sonnet-4-20250514, claude-opus-4-20250514gemini/gemini-1.5-pro, gemini/gemini-1.5-flashmistral/mistral-large-latestFull list: https://docs.litellm.ai/docs/providers
β‘ When to Use
π‘ Examples
import litellmCall any model with unified API
response = litellm.completion(
model="gpt-4o",
messages=[{"role": "user", "content": "Explain this code"}]
)
print(response.choices[0].message.content)