2.8 KiB
2.8 KiB
部署指南
目标节点
OMV (Open Media Vault) on NAS / Proxmox
推荐直接跑在 Nas 上,不强制 Docker,直接 Python 运行。
步骤 1 — 环境准备
检查 Python 版本
python3 --version # 需要 >= 3.9
创建用户(可选,推荐)
useradd -m -s /bin/bash litellm
su - litellm
mkdir -p ~/litellm-gateway
步骤 2 — 安装依赖
pip install litellm
可选:
pip install uvicorn[standard] # ASGI 服务器(生产推荐)
步骤 3 — 配置
cd ~/litellm-gateway
# 复制环境变量模板
cp .env.example .env
# 编辑 .env,填入真实值
nano .env
必须设置的值:
MINIMAX_API_KEY— MiniMax 真实 API KeyLITELLM_MASTER_KEY— 管理员 key(以sk-开头)
步骤 4 — 启动
chmod +x run.sh
./run.sh
后台运行(生产):
# nohup
nohup ./run.sh > logs/litellm.log 2>&1 &
# 或用 systemd(见下方)
步骤 5 — 验证
# 健康检查
curl http://localhost:4000/health
# 测试 chat completions
curl -X POST http://localhost:4000/v1/chat/completions \
-H "Authorization: Bearer sk-your-master-key" \
-H "Content-Type: application/json" \
-d '{
"model": "MiniMax-M2.7",
"messages": [{"role": "user", "content": "Hello"}]
}'
步骤 6 — OpenClaw 接入
在 ~/.openclaw/openclaw.json 中修改 MiniMax provider:
{
"providers": {
"minimax": {
"apiKey": "sk-your-minimax-api-key"
},
"minimax-portal": {
"apiKey": "sk-your-litellm-key",
"baseURL": "http://<your-server>:4000/v1"
}
}
}
⚠️ 注意:LiteLLM 使用 OpenAI 兼容接口,所以 OpenClaw 的
minimax-portalprovider 可以直接指向 LiteLLM 的/v1端点。
systemd 服务(OMV 持久化)
# /etc/systemd/system/litellm.service
[Unit]
Description=LiteLLM Gateway
After=network.target
[Service]
Type=simple
User=litellm
WorkingDirectory=/home/litellm/litellm-gateway
ExecStart=/home/litellm/litellm-gateway/run.sh
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload
sudo systemctl enable litellm
sudo systemctl start litellm
网络访问控制
仅内网访问(推荐)
确保 LiteLLM 的端口 :4000 不暴露到公网。
Tailscale / ZeroTier 组网(推荐)
# 在服务器上安装 Tailscale
curl -fsSL https://tailscale.com/install.sh | sh
tailscale up --accept-routes
# OpenClaw 节点也加入同一网络
# 然后 LiteLLM 只监听 Tailscale IP(如 100.64.x.x:4000)
防火墙规则(OMV)
# 只允许内网段访问 4000
iptables -A INPUT -p tcp -s 192.168.1.0/24 --dport 4000 -j ACCEPT
iptables -A INPUT -p tcp --dport 4000 -j DROP