File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -10,3 +10,6 @@ NEWAPI_KEY=sk-newapi-dev-xxxx
1010LITELLM_MASTER_KEY = sk-litellm-123456
1111# LiteLLM 元数据数据库;未显式设置时 compose 会使用默认本地 PostgreSQL 地址。
1212DATABASE_URL = postgresql://postgres:12345678@host.docker.internal:5432/litellm
13+ # 可选兼容项:如果后续切回 `qwen.yaml` 这类百炼配置,再补这些变量即可。
14+ # DASHSCOPE_API_KEY=sk-dashscope-dev-xxxx
15+ # DASHSCOPE_API_BASE=https://dashscope.aliyuncs.com/compatible-mode/v1
Original file line number Diff line number Diff line change @@ -10,3 +10,6 @@ NEWAPI_KEY=sk-newapi-prod-change-me
1010LITELLM_MASTER_KEY=sk-litellm-prod-change-me
1111# 生产环境建议使用独立数据库账号,并限制到最小权限。
1212DATABASE_URL=postgresql://litellm:change-me@postgres.internal:5432/litellm
13+ # 可选兼容项:如果生产环境仍需切换到 DashScope / qwen.yaml,再提供这些变量。
14+ # DASHSCOPE_API_KEY=sk-dashscope-prod-change-me
15+ # DASHSCOPE_API_BASE=https://dashscope.aliyuncs.com/compatible-mode/v1
Original file line number Diff line number Diff line change @@ -6,19 +6,22 @@ services:
66 ports :
77 - " ${LITELLM_HOST_PORT:-34000}:4000"
88 environment :
9+ # 固定容器常量保留在 compose 内部,避免每个环境都重复维护这类不变值。
910 # LiteLLM 官方镜像会把 PORT 透传给内部 uvicorn 启动参数,未显式设置时会报错。
1011 PORT : " 4000"
1112 # 当前镜像需要显式提供配置文件路径;仅挂载 /app/config.yaml 并不会自动加载 model_list。
1213 CONFIG_FILE_PATH : " /app/config.yaml"
14+ # 下面这些值统一由 `--env-file .env.local` 提供,再通过白名单方式注入容器。
15+ # 这样可以避免把 `.env.local` 中与 LiteLLM 无关的变量一并注入容器。
1316 # 通过 compose 插值保留当前默认数据库地址;start.ps1 会在存在 .env.local 时传入 --env-file 以支持本地覆盖。
1417 DATABASE_URL : ${DATABASE_URL:-postgresql://postgres:12345678@host.docker.internal:5432/litellm}
1518 # 当前本地配置走 NewAPI OpenAI 兼容接口;变量必须显式注入容器,LiteLLM 才能解析 os.environ/...。
1619 NEWAPI_API_BASE : ${NEWAPI_API_BASE:-}
1720 NEWAPI_KEY : ${NEWAPI_KEY:-}
21+ LITELLM_MASTER_KEY : ${LITELLM_MASTER_KEY:-}
1822 # 保留旧变量,避免切回 qwen.yaml 等历史配置时还要额外补环境变量。
1923 DASHSCOPE_API_KEY : ${DASHSCOPE_API_KEY:-}
2024 DASHSCOPE_API_BASE : ${DASHSCOPE_API_BASE:-https://dashscope.aliyuncs.com/compatible-mode/v1}
21- LITELLM_MASTER_KEY : ${LITELLM_MASTER_KEY:-}
2225 volumes :
2326 - ./litellm.local.yaml:/app/config.yaml:ro
2427 extra_hosts :
Original file line number Diff line number Diff line change 1212- ` .env.production.example ` :生产环境变量示例。
1313- ` .env.local ` :本地私有环境变量,保存 ` NEWAPI_API_BASE ` 、` NEWAPI_KEY ` 、` LITELLM_MASTER_KEY ` 、可选 ` DATABASE_URL ` 。
1414
15+ 固定常量如 ` PORT=4000 ` 、` CONFIG_FILE_PATH=/app/config.yaml ` 保留在 ` compose.yaml ` 内部;环境差异值建议集中在 ` .env.local ` ,再通过 ` start.ps1 ` 追加的 ` --env-file ` 和 ` compose.yaml ` 的 ` environment ` 白名单注入到容器。
16+
1517## 环境变量
1618
1719建议先在 ` ai/gateway/litellm/.env.local ` 中配置以下值:
@@ -33,6 +35,7 @@ DATABASE_URL=postgresql://postgres:12345678@host.docker.internal:5432/litellm
3335- ` NEWAPI_KEY ` :LiteLLM 转发到 NewAPI 时使用的上游密钥。
3436- ` LITELLM_MASTER_KEY ` :LiteLLM Proxy 对外暴露的网关密钥。
3537- ` DATABASE_URL ` :LiteLLM 的数据库连接串;如果未配置,会回退到默认的宿主机 PostgreSQL 地址。
38+ - ` DASHSCOPE_API_KEY ` / ` DASHSCOPE_API_BASE ` :可选兼容项;只有切回 ` qwen.yaml ` 或其他百炼配置时才需要提供。
3639
3740如果你想准备生产环境变量,可直接复制 ` ./.env.production.example ` 再按实际环境改值。
3841
@@ -53,6 +56,11 @@ docker compose --env-file ai/gateway/litellm/.env.local `
5356 up -d
5457```
5558
59+ 说明:
60+
61+ - 这里保留 ` --env-file ` ,而不是把 ` .env.local ` 改成 ` env_file ` 主方案,是因为它同时负责 compose 插值,例如 ` image ` 、` ports ` 、` environment ` 中的 ` ${...} ` 。
62+ - ` compose.yaml ` 里的 ` environment ` 继续采用白名单注入,这样 ` .env.local ` 中与 LiteLLM 无关的变量不会自动进入容器。
63+
5664## 常用命令
5765
5866``` powershell
You can’t perform that action at this time.
0 commit comments