litellm
БесплатноБез исполняемых скриптовНе проверенLiteLLM is a Python SDK and self-hosted proxy that calls 100+ LLM providers (OpenAI, Anthropic, Google Gemini, Mistral, Bedrock, Ollama and more) through one…
от TerminalSkills★ 221 звезда на GitHubОб этом скилле
LiteLLM
Overview
LiteLLM gives you one function, completion(), for 100+ providers, always returning an OpenAI-format response. Switch providers by changing the model string provider/model. As a proxy server (AI gateway) it adds an OpenAI-compatible HTTP endpoint, load balancing, fallbacks, virtual API keys, budgets, rate limits and spend tracking for teams.
Security first. On 24 March 2026 PyPI releases 1.82.7 and 1.82.8 were malicious (a credential stealer, live about 40 minutes, since yanked). Versions up to 1.82.6 and releases from 1.83.0 on are clean, and the official Docker image was not affected. Always pin an exact version (litellm==1.103.2, or whichever release you have reviewed), commit a lock file, and install in a virtual environment or container rather than a machine that holds cloud credentials.
Instructions
Install
python -m venv .venv && source .venv/bin/activate
pip install 'litellm==1.103.2' # SDK only
pip install 'litellm[proxy]==1.103.2' # SDK + proxy server (adds the `litellm` server command)
Docker alternative for the proxy: docker.litellm.ai/berriai/litellm (also on ghcr.io/berriai/litellm). Prefer a -stable tag and pin it. Images on GHCR are signed with cosign; the README shows how to verify.
SDK
Set provider keys in environment variables (OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY); LiteLLM picks them up.
from litellm import completion
msgs = [{"role": "user", "content": "Summarize RFC 9110 in two sentences."}]
r = completion(model="openai/gpt-4o-mini", messages=msgs)
r = completion(model="anthropic/claude-sonnet-4-5", messages=msgs)
r = completion(model="gemini/gemini-flash-latest", messages=msgs)
r = completion(model="ollama/llama3.1", messages=msgs, api_base="http://localhost:11434")
print(r.choices[0].message.content) # same shape for every provider
Always include the provider/ prefix. Model IDs change often; take the exact string from https://docs.litellm.ai/docs/providers. stream=True, tools/function calling and response_format work across providers where the upstream model supports them. For tests, pass mock_response="ok" to get a canned reply without any API call.
Router (in-process load balancing and fallbacks)
import os
from litellm import Router
router = Router(
model_list=[
{"model_name": "smart", "litellm_params": {
"model": "anthropic/claude-sonnet-4-5", "api_key": os.environ["ANTHROPIC_API_KEY"]}},
{"model_name": "fast", "litellm_params": {
"model": "openai/gpt-4o-mini", "api_key": os.environ["OPENAI_API_KEY"]}},
],
fallbacks=[{"smart": ["fast"]}],
num_retries=2,
routing_strategy="simple-shuffle",
)
r = router.completion(model="smart", messages=msgs)
Several entries with the same model_name form one pool that is load balanced. Valid routing_strategy values: simple-shuffle (default, recommended), latency-based-routing, least-busy, cost-based-routing, and the Redis-backed usage-based-routing and usage-based-routing-v2. There are also context_window_fallbacks (prompt too long) and content_policy_fallbacks.
Proxy server
# litellm_config.yaml
model_list:
- model_name: smart
litellm_params:
model: anthropic/claude-sonnet-4-5
api_key: os.environ/ANTHROPIC_API_KEY
- model_name: smart # same name = load balanced pool
litellm_params:
model: openai/gpt-4o
api_key: os.environ/OPENAI_API_KEY
- model_name: fast
litellm_params:
model: openai/gpt-4o-mini
api_key: os.environ/OPENAI_API_KEY
router_settings:
routing_strategy: simple-shuffle
num_retries: 3
request_timeout: 30
fallbacks: [{"smart": ["fast"]}]
general_settings:
master_key: os.environ/LITELLM_MASTER_KEY # must start with "sk-"
database_url: os.environ/DATABASE_URL # PostgreSQL, needed for virtual keys and spend
export LITELLM_MASTER_KEY=sk-$(openssl rand -hex 24)
litellm --config litellm_config.yaml --port 4000
curl http://localhost:4000/health # health endpoint
docker run --rm -p 4000:4000 \
-v "$PWD/litellm_config.yaml:/app/config.yaml" \
-e OPENAI_API_KEY -e ANTHROPIC_API_KEY -e LITELLM_MASTER_KEY -e DATABASE_URL \
docker.litellm.ai/berriai/litellm:main-stable --config /app/config.yaml
Verify the exact tag on the docs quickstart before using it. Any OpenAI client works against the proxy:
import OpenAI from "openai";
const client = new OpenAI({ baseURL: "http://localhost:4000/v1", apiKey: process.env.LITELLM_KEY });
const r = await client.chat.completions.create({
model: "smart",
messages: [{ role: "user", content: "Explain monads simply." }],
});
Virtual keys, budgets and spend
With database_url set, create per-user or per-team keys with limits, instead of handing out the master key:
curl -s http://localhost:4000/key/generate \
-H "Aut
Установить litellm в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл litellm?
LiteLLM is a Python SDK and self-hosted proxy that calls 100+ LLM providers (OpenAI, Anthropic, Google Gemini, Mistral, Bedrock, Ollama and more) through one OpenAI-compatible interface. Use when someone asks to "switch between LLM providers", "LiteLLM", "unified LLM API", "LLM proxy", "call Claude and GPT with the same code", "LLM load balancing", "fallbacks between models", or "multi-model AI gateway". Covers SDK calls, Router, fallbacks, virtual keys, budgets and spend tracking.
Как установить скилл litellm?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл litellm запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
mcp-builder
Guide for creating high-quality MCP (Model Context Protocol) servers that enable LLMs to interact with external services through well-designed tools. Use when…
от Anthropicclaude-api
Reference for the Claude API / Anthropic SDK — model ids, pricing, params, streaming, tool use, MCP, agents, caching, token counting, model migration. TRIGGER…
от Anthropicalgorithmic-art
Creating algorithmic art using p5.js with seeded randomness and interactive parameter exploration. Use this when users request creating art using code…
от Anthropicmcp-integration
This skill should be used when the user asks to "add MCP server", "integrate MCP", "configure MCP in plugin", "use .mcp.json", "set up Model Context…
от Anthropic