Skip to content

Commit 5896e47

Browse files
committed
refactor(ai/gateway): 优化 LiteLLM 配置文件结构
重构 newapi.yaml 配置文件,引入 YAML 锚点和引用机制来减少重复配置。 为 NewAPI 和智谱 AI 分别定义公共参数锚点,通过 <<: 引用方式复用连接 配置,提升配置文件可维护
1 parent 47fcf96 commit 5896e47

1 file changed

Lines changed: 16 additions & 14 deletions

File tree

ai/gateway/litellm/newapi.yaml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,48 @@
11
model_list:
22
# 显式注册 OpenAI 系列模型,确保 `/models` 能直接返回可用模型名。
33
- model_name: "gpt-5.4"
4-
litellm_params:
5-
# `model_name` 保持与上游模型 id 一致,便于客户端直接按 `/models` 结果发起调用。
6-
model: "openai/gpt-5.4"
4+
litellm_params: &newapi_openai_params
5+
# 这里顺手定义 NewAPI OpenAI 兼容入口的公共连接参数,后续同上游模型通过 merge 复用。
76
api_base: "os.environ/NEWAPI_API_BASE" # 从环境变量读 NewAPI 地址
87
api_key: "os.environ/NEWAPI_KEY" # 从环境变量读密钥
8+
# `model_name` 保持与上游模型 id 一致,便于客户端直接按 `/models` 结果发起调用。
9+
model: "openai/gpt-5.4"
910
# 显式注册 Gemini 系列模型,避免 wildcard 路由只返回 `*`。
1011
- model_name: "gemini-3.1-pro"
1112
litellm_params:
13+
# 复用同一个 NewAPI OpenAI 兼容入口,只覆盖具体模型名。
14+
<<: *newapi_openai_params
1215
# 继续走 OpenAI 兼容入口,由 NewAPI 负责实际模型分发。
1316
model: "openai/gemini-3.1-pro"
14-
api_base: "os.environ/NEWAPI_API_BASE" # 从环境变量读 NewAPI 地址
15-
api_key: "os.environ/NEWAPI_KEY" # 从环境变量读密钥
1617
# 显式注册 Claude 系列模型,便于 LiteLLM 直接暴露固定模型列表。
1718
- model_name: "claude-opus-4-6"
1819
litellm_params:
20+
# 复用同一个 NewAPI OpenAI 兼容入口,只覆盖具体模型名。
21+
<<: *newapi_openai_params
1922
# 使用上游真实模型 id,避免代理别名与 NewAPI 模型名脱节。
2023
model: "openai/claude-opus-4-6"
21-
api_base: "os.environ/NEWAPI_API_BASE" # 从环境变量读 NewAPI 地址
22-
api_key: "os.environ/NEWAPI_KEY" # 从环境变量读密钥
2324
# 显式注册 GLM Coding Plan 主模型,便于 `/models` 稳定暴露官方模型名。
2425
- model_name: "GLM-5.1"
25-
litellm_params:
26-
# 智谱 Coding Plan 走独立 OpenAI 兼容端点,继续复用 LiteLLM 的 OpenAI provider。
27-
model: "openai/GLM-5.1"
26+
litellm_params: &zai_openai_params
27+
# 这里定义智谱 Coding Plan OpenAI 兼容入口的公共连接参数,便于同系列模型复用。
2828
api_base: "os.environ/Z_AI_CODING_API_BASE" # 从环境变量读智谱 Coding Plan 地址
2929
api_key: "os.environ/Z_AI_API_KEY" # 从环境变量读智谱密钥
30+
# 智谱 Coding Plan 走独立 OpenAI 兼容端点,继续复用 LiteLLM 的 OpenAI provider。
31+
model: "openai/GLM-5.1"
3032
# 为其它官方 GLM 模型保留专属兜底,避免误落到最后的全局 `* -> NewAPI`。
3133
- model_name: "GLM-*"
3234
litellm_params:
35+
# 复用智谱 Coding Plan OpenAI 兼容入口,只覆盖具体模型名。
36+
<<: *zai_openai_params
3337
# 由 LiteLLM 按请求中的官方模型名透传,例如 `GLM-4.7`。
3438
model: "openai/GLM-*"
35-
api_base: "os.environ/Z_AI_CODING_API_BASE" # 从环境变量读智谱 Coding Plan 地址
36-
api_key: "os.environ/Z_AI_API_KEY" # 从环境变量读智谱密钥
3739
# 把 wildcard 路由放在最后,优先命中显式模型,其余上游模型再走透传兜底。
3840
- model_name: "*"
3941
litellm_params:
42+
# 复用同一个 NewAPI OpenAI 兼容入口,只覆盖具体模型名。
43+
<<: *newapi_openai_params
4044
# 对列表外但 NewAPI 已存在的模型保留透传能力,例如 `gpt-5.4-mini`。
4145
model: "openai/*"
42-
api_base: "os.environ/NEWAPI_API_BASE" # 从环境变量读 NewAPI 地址
43-
api_key: "os.environ/NEWAPI_KEY" # 从环境变量读密钥
4446

4547
litellm_settings:
4648
# 本地代理统一关闭遥测,避免开发环境把调用元数据发送到外部。

0 commit comments

Comments
 (0)