第二十七轮: 三线直传(/v1/messages,/v1/responses)+删除路由别名;第二十八轮: element-plus 按需引入+死代码清理+前端支持格式列/API Key 文档

This commit is contained in:
api-gateway committed 2026-09-18 16:33:33 +08:00
1 parent 1b54802ad3
commit 4c1973b13d
28 files changed
+3016 -1263

No files matched your search

+143 -57
View File
@@ -25,7 +25,7 @@ providers:
display_name: "Agnes 3.0 Flash"
type: "text"
# 第十三轮: Agnes 3.0 Flash 文档「输入模态:文本、图像 URL」→ 支持视觉(对话带图)。
# 实测 data:image/png;base64,... 也能识别。带图请求走路由别名时会被排到链首。
# 实测 data:image/png;base64,... 也能识别。
vision: true
- id: "agnes-2.5-flash"
display_name: "Agnes 2.5 Flash"
@@ -57,35 +57,71 @@ providers:
base_url: "https://opencode.ai/zen/go/v1"
auth:
token_env: "OPENCODE_API_KEY"
# OpenCode Go 是每月订阅编程模型入口。官方硬性要求每个 /chat/completions
# 带 x-opencode-session(缺失直接 400 MissingSessionID),并建议用专属 UA
# OpenCode Go 是每月订阅编程模型入口。官方硬性要求**三条线**都带
# x-opencode-session(缺失直接 400 MissingSessionID),并建议用专属 UA
# 而非通用库名(实测 UA 不敏感,会话头才是必需)。适配器据此开关在
# 每次请求动态注入 UUID 会话头(不能放静态 extra_headers——会被 _get_adapter 缓存冻结)。
# 每次请求动态注入会话头(不能放静态 extra_headers——会被 _get_adapter 缓存冻结)。
requires_session_header: true
extra_headers:
User-Agent: "api-gateway/2.4.0 (jakon opencode-go)"
# 无媒体能力(纯文本编程模型;图像/视频不走本供应商)
media: {}
# ── 协议线(第二十七轮「三线直传」)──────────────────────────
# 同一家供应商的三条线共用 base_url,只有「路径 + 鉴权方式 + 固定头」不同。
# 实测(2026-09-18,真实 key):
# /chat/completions 与 /responses → Authorization: Bearer
# /messages → x-api-key(用 Bearer 打会 401 Missing API key)
# 缺少 anthropic-version 时 /messages 也会被拒 → 作为该线固定头带上。
# 语义:**这里没写的线 = 该供应商没有这条线**(模型就算声明了也调用不了,
# validate_config 会直接报错拦住)。老板决策:先只做 OpenCode 一家,
# 其余供应商(Agnes / 火山)暂不声明 → 走默认值 = 只认 chat/completions,
# 行为与改造前完全一致。
endpoints:
chat/completions:
path: "/chat/completions"
auth: "bearer"
messages:
path: "/messages"
auth: "x-api-key"
headers:
anthropic-version: "2023-06-01"
responses:
path: "/responses"
auth: "bearer"
# ── 模型 ─────────────────────────────────────────────────
# models[].protocols = 该模型**能用哪几条线**(入站格式必须与出站一致)。
# 取值:chat/completions | messages | responses;不写 = 只认 chat/completions。
# 实测口径(2026-09-18 全量扫描 29 个文档模型 × 3 条线,非文档线另做
# 「流式 + 工具调用」复核,全部 200):官方文档标注的线**一定**可用;
# 另外有一批模型实测能走多条线(OpenCode 侧自带跨格式适配),按实测多标:
# · 四条 DeepSeek 三线全通(chat + messages + responses)
# · kimi-k3 / minimax-m3 / minimax-m2.5 / qwen3.6~3.8 系列:chat + messages
# 反向证据(为什么必须逐条实测而不是"猜全支持"):把只认 chat 的 glm 系打到
# /messages 上是 500 Internal server error,把 messages 线的模型打到
# /responses 上是 401 "not supported for format openai" —— 都不像"选错格式",
# 所以网关改成按本表拦在入口(400 并说清该模型支持哪些线)。
models:
# ── OpenAI 兼容 /v1/chat/completions 线(全部经真实 key 实测 200)──
# ── OpenAI Chat Completions 线 ────────────────────────
- id: "glm-5.3-flash"
display_name: "GLM-5.3-Flash"
type: "text"
protocols: ["chat/completions"]
- id: "glm-5.3"
display_name: "GLM-5.3"
type: "text"
protocols: ["chat/completions"]
- id: "glm-5.2"
display_name: "GLM-5.2"
type: "text"
protocols: ["chat/completions"]
- id: "glm-5.1"
display_name: "GLM-5.1"
type: "text"
- id: "kimi-k3"
display_name: "Kimi K3"
type: "text"
protocols: ["chat/completions"]
- id: "kimi-k2.7-code"
display_name: "Kimi K2.7 Code"
type: "text"
protocols: ["chat/completions"]
# 上游硬约束:该模型**只接受 temperature=1**,传 0 / 0.7 等一律 400
# "invalid temperature: only 1 is allowed for this model"。
# 写死后网关无论收到什么温度都按 1 发(前端温度滑块、API 传参、一键测速探针
@@ -95,44 +131,120 @@ providers:
- id: "kimi-k2.6"
display_name: "Kimi K2.6"
type: "text"
protocols: ["chat/completions"]
- id: "longcat-2.0"
display_name: "LongCat 2.0"
type: "text"
- id: "deepseek-v4-pro"
display_name: "DeepSeek V4 Pro"
protocols: ["chat/completions"]
- id: "mimo-v2.5"
display_name: "MiMo V2.5"
type: "text"
- id: "deepseek-v4-flash"
display_name: "DeepSeek V4 Flash"
protocols: ["chat/completions"]
- id: "mimo-v2.5-pro"
display_name: "MiMo V2.5 Pro"
type: "text"
- id: "deepseek-flash"
display_name: "DeepSeek Flash"
protocols: ["chat/completions"]
- id: "hy4-preview"
display_name: "Hy4 Preview"
type: "text"
protocols: ["chat/completions"]
- id: "hy3"
display_name: "Hy3"
type: "text"
protocols: ["chat/completions"]
# ── Chat + Messages 两条线都实测可用 ─────────────────
- id: "kimi-k3"
display_name: "Kimi K3"
type: "text"
protocols: ["chat/completions", "messages"]
- id: "minimax-m3"
display_name: "MiniMax M3"
type: "text"
protocols: ["chat/completions", "messages"]
- id: "minimax-m2.5"
display_name: "MiniMax M2.5"
type: "text"
protocols: ["chat/completions", "messages"]
- id: "qwen3.8-max"
display_name: "Qwen3.8 Max"
type: "text"
protocols: ["chat/completions", "messages"]
- id: "qwen3.8-flash"
display_name: "Qwen3.8 Flash"
type: "text"
protocols: ["chat/completions", "messages"]
- id: "qwen3.7-max"
display_name: "Qwen3.7 Max"
type: "text"
protocols: ["chat/completions", "messages"]
- id: "qwen3.7-plus"
display_name: "Qwen3.7 Plus"
type: "text"
protocols: ["chat/completions", "messages"]
- id: "qwen3.6-plus"
display_name: "Qwen3.6 Plus"
type: "text"
protocols: ["chat/completions", "messages"]
# ── 三条线全通(实测 chat / messages / responses 均 200,
# 非文档线另经流式 + 工具调用复核) ────────────────
- id: "deepseek-v4.1-flash"
display_name: "DeepSeek V4.1 Flash"
type: "text"
vision: true # 2026-09-18 实测确认多模态:data:image/png;base64 红/蓝/绿三色均识别正确;
# 同一带图请求打到纯文本模型 deepseek-v4-flash 会被上游 400 拒(对照有效)。
protocols: ["chat/completions", "messages", "responses"]
- id: "deepseek-v4-pro"
display_name: "DeepSeek V4 Pro"
type: "text"
protocols: ["chat/completions", "messages", "responses"]
- id: "deepseek-v4-flash"
display_name: "DeepSeek V4 Flash"
type: "text"
protocols: ["chat/completions", "messages", "responses"]
- id: "deepseek-v4-flash-vision-exp"
display_name: "DeepSeek V4 Flash Vision Exp"
type: "text"
vision: true # 官方标 Vision,支持图像转 token 输入(带图请求可走路由链首)
- id: "mimo-v2.5"
display_name: "MiMo V2.5"
vision: true # 官方标 Vision,支持图像转 token 输入
protocols: ["chat/completions", "messages", "responses"]
# ── Anthropic Messages 线(文档主推这条)─────────────
- id: "minimax-m2.7"
display_name: "MiniMax M2.7"
type: "text"
- id: "mimo-v2.5-pro"
display_name: "MiMo V2.5 Pro"
# 实测:messages 线 200,chat / responses 都是 500 → 只标 messages
protocols: ["messages"]
- id: "union-alpha"
display_name: "Union Alpha Free"
type: "text"
- id: "hy4-preview"
display_name: "Hy4 Preview"
# 文档标的 messages 线,但实测上游回 400「Model is unavailable.」
# (限时免费模型,额度/可用性由上游控制)。先按文档收录并标注真实线,
# 调用时上游的不可用会原样回给客户端(网关不替它编文案)。
protocols: ["messages"]
# ── OpenAI Responses 线 ───────────────────────────────
- id: "grok-4.6"
display_name: "Grok 4.6"
type: "text"
- id: "hy3"
display_name: "Hy3"
# 实测:responses 200;chat / messages 都是 401 "not supported for format"
protocols: ["responses"]
- id: "gpt-5.6-luna"
display_name: "GPT 5.6 Luna"
type: "text"
protocols: ["responses"]
- id: "muse-spark-1.3-contributor"
display_name: "Muse Spark 1.3 Contributor"
type: "text"
# 实测三条线都 403 DataPolicyError:该模型会拿数据训练,需要先在
# OpenCode 控制台**显式同意数据条款**才能调用(当前工作区未同意)。
# 先收录并标好线:老板去控制台点了同意就能直接用,不用再改网关。
protocols: ["responses"]
- id: "muse-spark-1.2-contributor"
display_name: "Muse Spark 1.2 Contributor"
type: "text"
protocols: ["responses"]
server:
host: "127.0.0.1"
port: 8808
timeout: 120
retry: 3 # 直接用模型 id(不走路由)时重试 3 次(含首次);路由别名用各自 route.retry(默认1)
retry: 3 # 同一模型的重试次数(含首次)。第二十七轮: 路由别名已删除,无 route.retry
# ── 运维开关 ──
health_auth: false # /health/* 是否也需鉴权(默认否,留给探活)
hot_reload: true # 监听 gateway.yaml mtime 自动重载(改配置免重启)
@@ -195,36 +307,10 @@ download:
auth:
session_ttl_minutes: 1440
# ── 路由别名 + 按优先级 fallback ──────────────────────
# model 填别名(如 wjd),按数组顺序逐个尝试:
# 第 1 个失败/超时/重试耗尽 → 第 2 个 … 全失败才 502。
# 每个路由可设 timeout(单模型超时秒)、retry(切下一个前该模型重试次数)。
# 优先级从左到右(第一个最高)。老板决策:wjd 链路 = 全部文本模型(已含 OpenCode Go 17 个)。
routes:
wjd:
timeout: 60 # 单模型 60s 没出结果就切下一个(避免 20×120s 挂死)
retry: 1 # 每个模型只试 1 次,失败立即切下一个
# 注意(老板决策):wjd 链路 = 全部文本模型;新增/现有文本模型都必须加进这里。
models:
# 供应商按「默认主力」在前,其余按供应商分组;运行时仍按可用性+速度实时重排。
- "ark-code-latest" # 1) 火山方舟
- "agnes-3.0-flash" # 2) Agnes 3.0
- "agnes-2.5-flash" # 3) Agnes 2.5
# ── 4) OpenCode Go(17 个文本模型,全进 wjd)──
- "glm-5.3-flash" # 4.1) GLM-5.3-Flash
- "glm-5.3" # 4.2) GLM-5.3
- "glm-5.2" # 4.3) GLM-5.2
- "glm-5.1" # 4.4) GLM-5.1
- "kimi-k3" # 4.5) Kimi K3
- "kimi-k2.7-code" # 4.6) Kimi K2.7 Code
- "kimi-k2.6" # 4.7) Kimi K2.6
- "longcat-2.0" # 4.8) LongCat 2.0
- "deepseek-v4-pro" # 4.9) DeepSeek V4 Pro
- "deepseek-v4-flash" # 4.10) DeepSeek V4 Flash
- "deepseek-flash" # 4.11) DeepSeek Flash
- "deepseek-v4.1-flash" # 4.12) DeepSeek V4.1 Flash
- "deepseek-v4-flash-vision-exp" # 4.13) DeepSeek V4 Flash Vision Exp
- "mimo-v2.5" # 4.14) MiMo V2.5
- "mimo-v2.5-pro" # 4.15) MiMo V2.5 Pro
- "hy4-preview" # 4.16) Hy4 Preview
- "hy3" # 4.17) Hy3
# ── 路由别名 / fallback 链:已整体删除 ──────────────────
# 第二十七轮(老板 2026-09-18 决策):**路由别名功能整体删除**,不再有 routes 段。
# 原因:三线直传落地后"入站格式 = 出站格式",模型 id 必须与协议线一一对应;
# 再套一层"自动挑最快模型"的别名,会把调用方选定的格式/能力(视觉、工具、协议线)
# 悄悄换掉。现在调用方直接填真实模型 id;要换模型就换 id,网关不再替谁做主。
# 老配置里残留的 routes 段会被忽略(不会让进程起不来),日志里有 warning 可查。
# 一键测速(Models 页每个模型后面的)不受影响,仍然逐个模型实测延迟。