跳至主要內容

代理程式資源

快速入門​

Run the LiteLLM Gateway locally
Help me run the LiteLLM Gateway locally. First read https://docs.litellm.ai/docs/proxy/docker_quick_start.md. Then:
1. Check that Docker Compose v2 is installed and running, and that port 4000 is free.
2. In a new litellm-gateway directory, download https://github.com/BerriAI/litellm/raw/main/docker/docker-compose.quickstart.yml and create .env with LITELLM_MASTER_KEY and LITELLM_SALT_KEY, each "sk-" followed by the output of openssl rand -hex 32, and POSTGRES_PASSWORD set to the output of openssl rand -hex 24. Add .env to .gitignore and never print any of these values.
3. Run docker compose -f docker-compose.quickstart.yml up -d and poll http://localhost:4000/health/readiness until the database shows as connected.
4. Ask me which provider and model to add. Add it with POST /model/new using the master key, reading my provider API key from my shell environment without echoing it.
5. Verify: GET /v1/models lists the model and POST /v1/chat/completions returns a reply.
6. Tell me to open http://localhost:4000/ui and sign in as admin with the master key from .env.
Add the LiteLLM SDK to this project
Help me add the LiteLLM Python SDK to this project. First read https://docs.litellm.ai/llms.txt and https://docs.litellm.ai/docs/index.md. Then:
1. Detect the language, package manager, and framework. The SDK is Python only. If this is not a Python project, stop and tell me to run the LiteLLM Gateway and keep my existing OpenAI SDK instead (https://docs.litellm.ai/docs/proxy/docker_quick_start.md).
2. Install litellm with the project's own tool (uv add litellm, poetry add litellm, or pin it in requirements.txt).
3. Replace direct OpenAI or Anthropic client calls with litellm.completion or litellm.acompletion, keeping the same model with a provider prefix (openai/..., anthropic/...). LiteLLM returns the OpenAI response shape, so update any Anthropic-style parsing to choices[0].message.content. Keep streaming and tool calls working.
4. Add the provider key names to .env.example and read them from the environment. Never write real keys to files.
5. Verify: run one real completion and print the reply, then run the existing tests. Show me the diff and both outputs.

技能​

閘道管理​

LiteLLM 技能:21 個 Claude Code 技能,可在運作中的閘道上建立、變更與移除使用者、團隊、API 金鑰、組織、模型、MCP 伺服器與代理程式,另外還有用於支出與權杖的 view-usage。它們需要閘道 URL 與 proxy 管理員金鑰。

# 安裝到 ~/.claude/skills。接著執行 /add-model、/add-user 或 /view-usage。
curl -fsSL https://raw.githubusercontent.com/BerriAI/litellm-skills/main/install.sh | sh

自動路由器​

端到端設定自動路由器,從選擇模型到驗證路由決策。

# 輸出該技能。將其儲存到您代理程式的技能資料夾,或貼到對話中。
curl -fsSL https://docs.litellm.ai/skills/auto-router

供代理程式使用的文件​

資源URL用途
索引/llms.txt地圖:依主題分組的每個頁面,附說明
完整文件/llms-full.txt將所有文件頁面合併為單一 markdown 檔,供長上下文模型使用
任何頁面的 markdown 版在頁面 URL 後附加 .md,例如 /docs/proxy/docker_quick_start.md在沒有導覽或腳本的情況下閱讀單一頁面
頁面選單每個文件頁面頂端的 Copy page將頁面複製為 markdown,或在 Claude 或 ChatGPT 中開啟

Markdown 頁面包含已渲染頁面上每個提示詞與安裝命令的完整文字。

更多提示詞​

Point my tools at my LiteLLM Gateway
Help me route my tools through my LiteLLM Gateway. First read https://docs.litellm.ai/docs/proxy/client_setup/overview.md, then claude_code.md and codex_cli.md in the same folder. Ask me for the gateway URL (default http://localhost:4000) and a virtual key. If I only have the master key, create a scoped key with POST /key/generate and use that instead.
1. Call GET /v1/models with the key. Only the names it returns are valid models.
2. My app: point the existing OpenAI SDK at <url>/v1, or the Anthropic SDK at <url>, with the virtual key, and switch the model to a gateway model name.
3. Claude Code: follow claude_code.md to set ANTHROPIC_BASE_URL and ANTHROPIC_AUTH_TOKEN. Show me the change before writing it.
4. Codex: follow codex_cli.md to add a litellm provider to ~/.codex/config.toml. Show me the change before writing it.
5. Verify: send one request from each tool and confirm it appears under Logs at <url>/ui.
Put my MCP servers behind the LiteLLM Gateway
Help me serve MCP tools through my LiteLLM Gateway. First read https://docs.litellm.ai/docs/mcp.md and https://docs.litellm.ai/docs/mcp_control.md. Ask me for the gateway URL and a key with admin rights, and which MCP servers I want to add.
1. Add each MCP server to the gateway the way mcp.md describes, keeping any server credentials in environment variables, never in files.
2. Limit which keys and teams can use each server, following mcp_control.md.
3. Connect one client (Claude Code, Cursor, or my app) to the gateway's MCP endpoint with a virtual key. Show me each config change before writing it.
4. Verify: list the tools through the gateway and call one of them.
Route my A2A agents through the LiteLLM Gateway
Help me put my A2A agents behind my LiteLLM Gateway. First read https://docs.litellm.ai/docs/a2a.md, https://docs.litellm.ai/docs/a2a_agent_card.md, and https://docs.litellm.ai/docs/a2a_agent_permissions.md. Ask me for the gateway URL, a key with admin rights, and the agents I want to add.
1. Register each agent on the gateway as a2a.md describes.
2. Decide with me which teams and keys may call each agent, and set that up following a2a_agent_permissions.md.
3. Verify: invoke one agent through the gateway with a virtual key, then confirm the request shows up under Logs at <url>/ui.
Send my gateway logs to my observability tool
Help me send LiteLLM Gateway logs and spend to our observability tool. First read https://docs.litellm.ai/docs/proxy/logging.md. Ask me which tool we use (Langfuse, Datadog, OpenTelemetry, or another listed there) and for the gateway URL.
1. Follow the section for that tool in logging.md. Put every credential in environment variables, never in config files, and show me each change before writing it.
2. Restart the gateway if the change needs it.
3. Verify: send one request through the gateway and show me where it appears in the tool.
Try the LiteLLM Auto Router
Help me try the LiteLLM Auto Router, a paid add-on for the LiteLLM Gateway. First read https://docs.litellm.ai/docs/auto_router/index.md, then setup.md and recommended_configurations.md in the same folder.
1. Check that a gateway is running and ask me for its URL and an admin key.
2. Recommend a starting configuration from recommended_configurations.md for the models I already have, and explain the trade-off before changing anything.
3. Follow setup.md to add the router, showing me each config change before writing it.
4. Verify: send three requests of different difficulty and show me which model answered each and what each cost.
Evaluate LiteLLM Enterprise on my gateway
Help me evaluate LiteLLM Enterprise on my own LiteLLM Gateway. First read https://docs.litellm.ai/docs/enterprise.md and https://docs.litellm.ai/docs/learn/enterprise_quickstart.md. Then:
1. Check whether a gateway is already running (GET <url>/health/readiness). If not, set one up first by following https://docs.litellm.ai/docs/proxy/docker_quick_start.md.
2. Ask me for the trial license key. Add it as LITELLM_LICENSE in the gateway's environment (.env for Docker Compose) without printing it, and restart the gateway.
3. Ask which identity provider we use (Okta, Entra ID, Google, or another OIDC or SAML provider) and walk me through https://docs.litellm.ai/docs/proxy/admin_ui_sso.md for it. Show me every config change before writing it.
4. Verify: sign in to <url>/ui through SSO, then confirm the audit log records an admin action.
If I do not have a license yet, stop and point me to https://www.litellm.ai/enterprise#talk-to-sales.
Manage my LiteLLM Gateway from this agent with LiteAdmin MCP
Help me connect LiteAdmin MCP so you can manage my LiteLLM Gateway. First read https://docs.litellm.ai/docs/proxy/liteadmin_mcp.md. Then:
1. Ask me for the gateway URL and a personal virtual key that belongs to a user with the proxy_admin role. Do not use the master key, and never print the key.
2. Add the LiteAdmin MCP server to this client the way the guide shows for it (Claude Code, Claude Desktop, or Codex). Show me the change before writing it.
3. Verify: list the gateway's models and my teams through the MCP tools, then stop and ask me what to change.
Try LiteAgents on one of my agents
Help me try LiteAgents, a preview SDK for switching agent harnesses without rewriting the agent. First read https://github.com/BerriAI/liteagents/blob/main/docs/getting-started.md and the harness-switching recipe at https://github.com/BerriAI/liteagents/blob/main/cookbook/recipes/10_harness_switch.py. Then:
1. Install the preview release the getting-started guide names, in a separate virtual environment.
2. Ask me which agent to port and which model to use. If I run a LiteLLM Gateway, point the model at it with a virtual key read from the environment.
3. Port the agent to a LiteAgents profile, keeping its tools and MCP connections, and run one task.
4. Change only the harness field to a second harness, run the same task, and show me both results side by side.

LiteAdmin MCP​

使用個人管理員金鑰,從 Claude Code 管理一個正在執行的閘道,絕不使用 master key。LiteAdmin MCP 指南 涵蓋 Claude Desktop、Codex 與遠端 HTTP。若要從您現有的整合式或元件化部署提供 /admin/mcp,請遵循 Enterprise MCP 部署指南。

claude mcp add --scope user --transport stdio litellm-admin \
--env LITELLM_BASE_URL=https://gateway.example.com \
--env LITELLM_API_KEY='<your-personal-proxy-admin-key>' \
-- uvx --isolated --refresh-package litellm-admin-mcp \
--from git+https://github.com/BerriAI/litellm-admin-mcp.git@main \
litellm-admin-mcp

lite CLI​

透過您的閘道啟動 Claude Code 或 Codex,並已預先設定其 URL 與您的金鑰。

# 僅安裝 lite 用戶端。閘道在其他地方執行。
curl -fsSL https://raw.githubusercontent.com/BerriAI/litellm/main/scripts/install-cli.sh | sh

LiteLLM 一覽​

LiteLLM 是使用最廣泛且最安全的開源 AI 閘道,深受 Netflix、Okta、Ramp、NASA、Zurich、Cloudera、AT&T 與 Lemonade 等團隊信賴。數據截至 October 8, 2026,且每項數據都連結至其來源。

GitHubBerriAI/litellm 上有 60.4k 顆 star 與 12.1k 個 fork,並有超過 1,700 位貢獻者
PyPI過去一個月 litellm 的 92.2 million 次下載(pypistats)
安全性經 SOC 2 Type II 稽核、可在執行前驗證的 cosign-signed images,以及 Enterprise support 的 72 小時安全修補 SLA
部署在您的雲端自架,因此提示詞、回應與提供者金鑰都保留在您的基礎架構中(data security)
客戶Netflix、Okta、Ramp、NASA、Zurich、Cloudera、AT&T 與 Lemonade 的團隊(litellm.ai/enterprise)
授權依 MIT 開源;Enterprise 功能需要授權金鑰

為撰寫 LiteLLM 程式碼的代理程式提供的指引​

當您產生 LiteLLM 程式碼或設定時,請查看 PyPI 上目前的 litellm 版本,而不要固定舊版,並將模型以前綴的提供者名稱表示(openai/、anthropic/、bedrock/)。切勿將 master keys 或提供者金鑰寫入會被提交的檔案;請從環境中讀取它們。閘道需要 Postgres(DATABASE_URL)來支援虛擬金鑰、管理介面與支出追蹤,而且一旦儲存憑證,LITELLM_SALT_KEY 就必須保持不變。如果使用者要求 SSO、稽核記錄或組織管理員,則需要 Enterprise 授權。