🚅 LiteLLM
LiteLLM AI网关
支持100+ LLM的开源AI网关。可自托管。企业级就绪。以OpenAI格式调用任何LLM。
LiteLLM代理服务器(AI网关) | 托管代理 | 企业版 | 网站
LiteLLM 是一个开源AI网关,为您提供单一、统一的接口,可使用OpenAI格式调用100+ LLM提供商——包括OpenAI、Anthropic、Gemini、Bedrock、Azure等。
您可以将其用作Python SDK进行直接库集成,或将AI网关(代理服务器) 部署为团队或组织的集中式服务。
跳转到 LiteLLM 代理(LLM网关)文档 跳转到支持的LLM提供商
跨提供商管理LLM调用很快会变得复杂——每个模型都有不同的SDK、身份验证模式、请求格式和错误类型。LiteLLM消除了这种摩擦:
Netflix
LLM - 调用100+ LLM(Python SDK + AI网关)
所有支持的端点 - /chat/completions、/responses、/embeddings、/images、/audio、/batches、/rerank、/a2a、/messages等。
uv add litellm
from litellm import completion
import os
os.environ["OPENAI_API_KEY"] = "your-openai-key"
os.environ["ANTHROPIC_API_KEY"] = "your-anthropic-key"
# OpenAI
response = completion(model="openai/gpt-4o", messages=[{"role": "user", "content": "Hello!"}])
# Anthropic
response = completion(model="anthropic/claude-sonnet-4-20250514", messages=[{"role": "user", "content": "Hello!"}])
快速开始 - 端到端教程 - 设置虚拟密钥,发出第一个请求
uv tool install 'litellm[proxy]'
litellm --model gpt-4o
import openai
client = openai.OpenAI(api_key="anything", base_url="http://0.0.0.0:4000")
response = client.chat.completions.create(
model="gpt-4o",
messages=[{"role": "user", "content": "Hello!"}]
)
文档:LLM提供商
| 提供商 | /chat/completions | /messages | /responses | /embeddings | /image/generations | /audio/transcriptions | /audio/speech | /moderations | /batches | /rerank |
|---|---|---|---|---|---|---|---|---|---|---|
Abliteration (abliteration) | ✅ | |||||||||
AI/ML API (aiml) | ✅ | ✅ | ✅ | ✅ | ✅ | |||||
AI21 (ai21) | ✅ | ✅ | ✅ | |||||||
AI21 Chat (ai21_chat) | ✅ | ✅ | ✅ | |||||||
| Aleph Alpha | ✅ | ✅ | ✅ | |||||||
| Amazon Nova | ✅ | ✅ | ✅ | |||||||
Anthropic (anthropic) | ✅ | ✅ | ✅ | ✅ | ||||||
Anthropic Text (anthropic_text) | ✅ | ✅ | ✅ | ✅ | ||||||
| Anyscale | ✅ | ✅ | ✅ | |||||||
AssemblyAI (assemblyai) | ✅ | ✅ | ✅ | ✅ | ||||||
Auto Router (auto_router) | ✅ | ✅ | ✅ | |||||||
AWS - Bedrock (bedrock) | ✅ | ✅ | ✅ | ✅ | ✅ | |||||
AWS - Sagemaker (sagemaker) | ✅ | ✅ | ✅ | ✅ | ||||||
Azure (azure) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
Azure AI (azure_ai) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |
Azure Text (azure_text) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |||
Baseten (baseten) | ✅ | ✅ | ✅ | |||||||
Bytez (bytez) | ✅ | ✅ | ✅ | |||||||
Cerebras (cerebras) | ✅ | ✅ | ✅ | |||||||
Clarifai (clarifai) | ✅ | ✅ | ✅ | |||||||
Cloudflare AI Workers (cloudflare) | ✅ | ✅ | ✅ | |||||||
Codestral (codestral) | ✅ | ✅ | ✅ | |||||||
Cohere (cohere) | ✅ | ✅ | ✅ | ✅ | ✅ | |||||
Cohere Chat (cohere_chat) | ✅ | ✅ | ✅ | |||||||
CometAPI (cometapi) | ✅ | ✅ | ✅ | ✅ | ||||||
CompactifAI (compactifai) | ✅ | ✅ | ✅ | |||||||
Custom (custom) | ✅ | ✅ | ✅ | |||||||
Custom OpenAI (custom_openai) | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | |||
Dashscope (dashscope) | ✅ | ✅ | ✅ | ✅ | ✅ | |||||
Databricks (databricks) | ✅ | ✅ | ✅ | |||||||
DataRobot (datarobot) | ✅ | ✅ | ✅ | |||||||
Deepgram (deepgram) | ✅ | ✅ | ✅ | ✅ | ||||||
DeepInfra (deepinfra) | ✅ | ✅ | ✅ | |||||||
Deepseek (deepseek) | ✅ | ✅ | ✅ | |||||||
ElevenLabs (elevenlabs) | ✅ | ✅ | ✅ | ✅ | ✅ | |||||
Empower (empower) | ✅ | ✅ | ✅ | |||||||
Fal AI (fal_ai) | ✅ | ✅ | ✅ | ✅ | ||||||
Featherless AI (featherless_ai) | ✅ | ✅ | ✅ | |||||||
Fireworks AI (fireworks_ai) | ✅ | ✅ | ✅ | |||||||
FriendliAI (friendliai) | ✅ | ✅ | ✅ | |||||||
Galadriel (galadriel) | ✅ | ✅ | ✅ | |||||||
GitHub Copilot (github_copilot) | ✅ | ✅ | ✅ | ✅ | ||||||
GitHub Models (github) | ✅ | ✅ | ✅ | |||||||
| Google - PaLM | ✅ | ✅ | ✅ | |||||||
Google - Vertex AI (vertex_ai) | ✅ | ✅ | ✅ | ✅ | ✅ | |||||
Google AI Studio - Gemini (gemini) | ✅ | ✅ | ✅ | |||||||
GradientAI (gradient_ai) | ✅ | ✅ | ✅ | |||||||
Groq AI (groq) | ✅ | ✅ | ✅ | |||||||
Heroku (heroku) | ✅ | ✅ | ✅ | |||||||
Hosted VLLM (hosted_vllm) | ✅ | ✅ | ✅ | |||||||
Huggingface (huggingface) | ✅ | ✅ | ✅ | ✅ | ✅ | |||||
Hyperbolic (hyperbolic) | ✅ | ✅ | ✅ | |||||||
IBM - Watsonx.ai (watsonx) | ✅ | ✅ | ✅ | ✅ | ||||||
Infinity (infinity) | ✅ | |||||||||
Jina AI (jina_ai) | ✅ | |||||||||
Lambda AI (lambda_ai) | ✅ | ✅ | ✅ | |||||||
Lemonade (lemonade) | ✅ | ✅ | ✅ | |||||||
LiteLLM Proxy (litellm_proxy) | ✅ | ✅ | ✅ | ✅ | ✅ | |||||
Llamafile (llamafile) | ✅ | ✅ | ✅ | |||||||
LM Studio (lm_studio) | ✅ | ✅ | ✅ | |||||||
Maritalk (maritalk) | ✅ | ✅ | ✅ | |||||||
| Meta - Llama API |
适用于需要更优安全性、用户管理和专业支持的企业
[获取企业版许可 与创始人交流
企业版包含:
我们欢迎对 LiteLLM 的贡献!无论是修复漏洞、添加功能还是改进文档,我们都感谢您的帮助。
需要先安装 uv。
git clone https://github.com/BerriAI/litellm.git
cd litellm
make install-dev # 安装开发依赖
make format # 格式化代码
make lint # 运行所有代码检查
make test-unit # 运行单元测试
make format-check # 仅检查格式
详细贡献指南,请参见 CONTRIBUTING.md。
[!NOTE] 想要为文档做贡献?LiteLLM 文档已迁移至独立仓库:https://github.com/BerriAI/litellm-docs%E3%80%82%E8%AF%B7%E5%9C%A8%E8%AF%A5%E4%BB%93%E5%BA%93%E6%8F%90%E4%BA%A4%E6%96%87%E6%A1%A3%E7%9B%B8%E5%85%B3%E7%9A%84 PR。文档托管于 docs.litellm.ai。
LiteLLM 遵循 https://google.github.io/styleguide/pyguide.html%E3%80%82
我们的自动化检查包括:
所有检查必须通过后,您的 PR 才能被合并。
请登录使用轩辕镜像享受快速拉取体验,支持国内访问优化,速度提升
docker pull ghcr.io/BerriAI/litellm:v1.83.3-stable.patch.3探索更多轩辕镜像的使用方法,找到最适合您系统的配置方式
通过 Docker 登录认证访问私有仓库
无需登录使用专属域名
Kubernetes 集群配置 Containerd
K3s 轻量级 Kubernetes 镜像加速
VS Code Dev Containers 配置
Podman 容器引擎配置
HPC 科学计算容器配置
ghcr、Quay、nvcr 等镜像仓库
Harbor Proxy Repository 对接专属域名
Portainer Registries 加速拉取
Nexus3 Docker Proxy 内网缓存
需要其他帮助?请查看我们的 常见问题Docker 镜像访问常见问题解答 或 提交工单
docker search 限制
站内搜不到镜像
离线 save/load
插件要用 plugin install
WSL 拉取慢
安全与 digest
新手拉取配置
镜像合规机制
manifest unknown
no matching manifest(架构)
invalid tar header(解压)
TLS 证书失败
DNS 超时
域名连通性排查
410 Gone 排查
402 与流量用尽
401 认证失败
429 限流
D-Bus 凭证提示
413 与超大单层
来自真实用户的反馈,见证轩辕镜像的优质服务