Files
xiaoyin-gateway/data/gateway.yaml
T
Jidekin 2eee87f5fa feat(provider): 接入 1min.AI(43 个模型)+ 独立同步脚本 + 「未监控」改「空闲」
老板:「查看 1min.ai 文档,把 1min 供应商加入 ai 网关项目里」。

### ① 新增 onemin 供应商
- base_url: https://api.1min.ai/openai/v1(OpenAI 兼容端点)
- 鉴权走 token_env: ONEMIN_API_KEY(不落明文,key 存 data/.env)
- 43 个模型,全部 chat/completions 单线
- **剔除 6 个与 opencode 重名的**(qwen3.7-plus / deepseek-v4-pro /
  glm-5.3 / glm-5.2 / gpt-5.6-luna / gpt-6-luna)—— 重名会让网关
  「按 id 调用始终命中先定义的那个」,把 opencode 的主路由抢走

### ② 新增 scripts/sync_onemin.py
独立同步脚本(不动 sync_models.py 的 3 家逻辑):
- 拉 GET /openai/v1/models(当前 49 个),与配置比对
- 新增补进配置、接口下线的删掉、**永远跳过与其他供应商重名的 id**
- 写盘走「备份 + 原子替换 + 回读校验」,校验不过自动还原
- 退出码:0 无变化/已同步 · 1 有漂移未写盘 · 2 抓取/写盘失败
- 已接入每日 05:00 的定时任务(步骤 1b)

### ③ 前端「未监控」→「空闲」
`circ_not_tracked` 的中文标签从「未监控」改成「空闲」,
英文从「Not monitored」改成「Idle」。

原因:熔断器是懒创建的 —— 供应商没被调用过就没有 breaker 实例,
`/health` 里 `circuit=not_tracked`。「未监控」听起来像监控坏了,
实际只是「还没被用过」。

### ④ .gitignore 补 *.bak-*
避免手工备份文件被误提交。

### 验证
- 直连 1min:GET /models → 200,49 个模型
- 经网关:/v1/models → 80 个(onemin 43 / opencode 26 / agnes 9 / dots 1)
- 实测调用 qwen3.7-flash / deepseek-flash 均正常返回
- 安全审查:12 类敏感模式(API Key / Token / 密码 / 私钥)0 命中
2026-11-01 23:01:54 +08:00

645 lines
34 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# AI 网关配置文件(data/ 目录)
# 供应商:Agnes / OpenCode Go(订阅编程模型)/ Dots AI
# 密钥统一走 token_env 指向的环境变量(本机见 data/.env),不再在 yaml 存明文
# 端口默认 8808
#
# 说明:本文件是项目的**唯一配置文件**(run.py 默认读取;GATEWAY_CONFIG 可覆盖)。
providers:
onemin:
name: "1min.AI"
base_url: "https://api.1min.ai/openai/v1"
auth:
token_env: "ONEMIN_API_KEY"
extra_headers: {}
# 2026-10-31 新增:1min.AI 的 OpenAI 兼容端点(https://api.1min.ai/openai/v1)
# 支持 /models、/chat/completions;聚合 OpenAI / DeepSeek / Qwen / GLM / Mistral / Kimi
# ⚠️ 与 opencode 重名的模型(glm-5.x / qwen3.7-plus / deepseek-v4-pro / gpt-5.6-luna 等)
# 已从本供应商剔除,保证 opencode 仍是主路由,不被 onemin 抢占。
models:
- id: "qwen3.7-max"
display_name: "Qwen3.7-max"
type: "text"
protocols: ["chat/completions"]
- id: "qwen3.7-flash"
display_name: "Qwen3.7-flash"
type: "text"
protocols: ["chat/completions"]
- id: "qwen3.6-plus"
display_name: "Qwen3.6-plus"
type: "text"
protocols: ["chat/completions"]
- id: "qwen3.6-flash"
display_name: "Qwen3.6-flash"
type: "text"
protocols: ["chat/completions"]
- id: "qwen-plus"
display_name: "Qwen-plus"
type: "text"
protocols: ["chat/completions"]
- id: "qwen-max"
display_name: "Qwen-max"
type: "text"
protocols: ["chat/completions"]
- id: "qwen-flash"
display_name: "Qwen-flash"
type: "text"
protocols: ["chat/completions"]
- id: "deepseek-flash"
display_name: "DeepSeek-flash"
type: "text"
protocols: ["chat/completions"]
- id: "magistral-small-latest"
display_name: "Magistral-small-latest"
type: "text"
protocols: ["chat/completions"]
- id: "magistral-medium-latest"
display_name: "Magistral-medium-latest"
type: "text"
protocols: ["chat/completions"]
- id: "ministral-14b-latest"
display_name: "Ministral-14b-latest"
type: "text"
protocols: ["chat/completions"]
- id: "open-mistral-nemo"
display_name: "Open Mistral-nemo"
type: "text"
protocols: ["chat/completions"]
- id: "mistral-small-latest"
display_name: "Mistral-small-latest"
type: "text"
protocols: ["chat/completions"]
- id: "mistral-small-2603"
display_name: "Mistral-small-2603"
type: "text"
protocols: ["chat/completions"]
- id: "mistral-medium-latest"
display_name: "Mistral-medium-latest"
type: "text"
protocols: ["chat/completions"]
- id: "mistral-medium-3-5"
display_name: "Mistral-medium-3-5"
type: "text"
protocols: ["chat/completions"]
- id: "mistral-large-latest"
display_name: "Mistral-large-latest"
type: "text"
protocols: ["chat/completions"]
- id: "mistral-large-2512"
display_name: "Mistral-large-2512"
type: "text"
protocols: ["chat/completions"]
- id: "gpt-6-sol"
display_name: "GPT-6-sol"
type: "text"
protocols: ["chat/completions"]
- id: "gpt-6-astra"
display_name: "GPT-6-astra"
type: "text"
protocols: ["chat/completions"]
- id: "gpt-5.6-terra"
display_name: "GPT-5.6-terra"
type: "text"
protocols: ["chat/completions"]
- id: "gpt-5.6-sol"
display_name: "GPT-5.6-sol"
type: "text"
protocols: ["chat/completions"]
- id: "gpt-5.5"
display_name: "GPT-5.5"
type: "text"
protocols: ["chat/completions"]
- id: "gpt-5.4-nano"
display_name: "GPT-5.4-nano"
type: "text"
protocols: ["chat/completions"]
- id: "gpt-5.4-mini"
display_name: "GPT-5.4-mini"
type: "text"
protocols: ["chat/completions"]
- id: "gpt-5.4"
display_name: "GPT-5.4"
type: "text"
protocols: ["chat/completions"]
- id: "gpt-5.2"
display_name: "GPT-5.2"
type: "text"
protocols: ["chat/completions"]
- id: "gpt-5.1"
display_name: "GPT-5.1"
type: "text"
protocols: ["chat/completions"]
- id: "gpt-5-nano"
display_name: "GPT-5-nano"
type: "text"
protocols: ["chat/completions"]
- id: "gpt-5-mini"
display_name: "GPT-5-mini"
type: "text"
protocols: ["chat/completions"]
- id: "gpt-5"
display_name: "GPT-5"
type: "text"
protocols: ["chat/completions"]
- id: "gpt-4o-mini"
display_name: "GPT-4o-mini"
type: "text"
protocols: ["chat/completions"]
- id: "gpt-4o"
display_name: "GPT-4o"
type: "text"
protocols: ["chat/completions"]
- id: "gpt-4.1-mini"
display_name: "GPT-4.1-mini"
type: "text"
protocols: ["chat/completions"]
- id: "gpt-4.1"
display_name: "GPT-4.1"
type: "text"
protocols: ["chat/completions"]
- id: "o3"
display_name: "o3"
type: "text"
protocols: ["chat/completions"]
- id: "moonshotai/kimi-k2.7-code"
display_name: "Moonshot kimi-k2.7-code"
type: "text"
protocols: ["chat/completions"]
- id: "moonshotai/kimi-k2.6"
display_name: "Moonshot kimi-k2.6"
type: "text"
protocols: ["chat/completions"]
- id: "meta/muse-spark-1.3"
display_name: "Meta muse-spark-1.3"
type: "text"
protocols: ["chat/completions"]
- id: "meta/muse-spark-1.2"
display_name: "Meta muse-spark-1.2"
type: "text"
protocols: ["chat/completions"]
- id: "meta/muse-spark-1.1"
display_name: "Meta muse-spark-1.1"
type: "text"
protocols: ["chat/completions"]
- id: "glm-5.1"
display_name: "GLM-5.1"
type: "text"
protocols: ["chat/completions"]
- id: "glm-5"
display_name: "GLM-5"
type: "text"
protocols: ["chat/completions"]
agnes:
name: "Agnes AI"
base_url: "https://api.agnes-ai.cn/v1"
auth:
token_env: "AGNES_API_KEY"
extra_headers: {}
# 图像 / 视频端点(Agnes 非标准,走自有路径)
media:
image_endpoint: "/images/generations"
image_default_size: "1K" # 图像默认档位(Agnes: 1K/2K/3K/4K)
video_create_endpoint: "/videos"
video_poll_base: "https://api.agnes-ai.cn"
video_poll_path: "/agnesapi"
# 视频默认模型(视频接口只用这一个):同步脚本**只保它不被自动删**,并在每日报告里
# 列出文档的视频清单;换默认由人点模型名(2026-09-24 定:不自动挑)。
# 候选见 Agnes 文档视频段:agnes-video-2.5 / agnes-video-2.5-flash / agnes-video-v2.0
video_model_name: "agnes-video-2.5-flash"
models:
- id: "agnes-3.0-flash"
display_name: "Agnes 3.0 Flash"
type: "text"
context_window: 512000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 65536 # 最大输出(token)
free: true # 2026-09-24 自动同步:文档「当前优惠」写当前免费(scripts/sync_models.py)
# 第十三轮: Agnes 3.0 Flash 文档「输入模态:文本、图像 URL」→ 支持视觉(对话带图)。
# 实测 data:image/png;base64,... 也能识别。
vision: true
- id: "agnes-2.5-flash"
display_name: "Agnes 2.5 Flash"
type: "text"
context_window: 512000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 65500 # 最大输出(token)
free: true # 2026-09-24 自动同步:文档「当前优惠」写当前免费(scripts/sync_models.py)
# Agnes 2.5 Flash(2.0 升级版):OpenAI 兼容 /v1/chat/completions,支持图像 URL 输入与工具调用,
# 上下文 512K / 最大输出 65.5K;当前定价暂免(¥0/百万)。参见官方文档 agnes-25-flash。
vision: true
- id: "agnes-image-2.5-flash"
display_name: "Agnes Image 2.5 Flash"
type: "image"
free: true # 2026-09-24 自动同步:文档「当前优惠」写当前免费(scripts/sync_models.py)
- id: "agnes-video-2.5-flash"
display_name: "Agnes Video 2.5 Flash"
type: "video"
free: true # 2026-09-24 自动同步:文档「当前优惠」写当前限时免费(scripts/sync_models.py)
free_limited: true # 限时免费;文档改口径后同步会自动撤掉这行
# 2026-09-24 自动同步:官方文档新增(scripts/sync_models.py)
- id: "agnes-2.5-pro"
display_name: "Agnes 2.5 Pro"
type: "text"
context_window: 1000000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 65536 # 最大输出(token)
# 文档现价 ¥3/M 输入、¥6/M 输出
# 2026-09-24 自动同步:官方文档新增(scripts/sync_models.py)
# 2026-09-24 自动同步:官方文档新增(scripts/sync_models.py)
- id: "agnes-image-2.0-flash"
display_name: "Agnes Image 2.0 Flash"
type: "image"
free: true # 2026-09-24 自动同步:文档「当前优惠」写当前免费(scripts/sync_models.py)
# 2026-09-24 自动同步:官方文档新增(scripts/sync_models.py)
- id: "agnes-image-2.1-flash"
display_name: "Agnes Image 2.1 Flash"
type: "image"
free: true # 2026-09-24 自动同步:文档「当前优惠」写当前免费(scripts/sync_models.py)
# 2026-09-24 自动同步:官方文档新增(scripts/sync_models.py)
- id: "agnes-video-2.5"
display_name: "Agnes Video 2.5"
type: "video"
# 2026-09-24 自动同步:官方文档新增(scripts/sync_models.py)
# 2026-10-21 自动同步:官方文档新增(scripts/sync_models.py)
- id: "agnes-2.5-pro-beta"
display_name: "Agnes 2.5 Pro Beta"
type: "text"
context_window: 1000000 # 同步 2026-10-21(scripts/sync_models.py)
max_output_tokens: 65536 # 同步 2026-10-21(scripts/sync_models.py)
# 文档现价 ¥3/M 输入、¥6/M 输出
opencode:
name: "OpenCode Go"
base_url: "https://opencode.ai/zen/go/v1"
auth:
token_env: "OPENCODE_API_KEY"
# OpenCode Go 是每月订阅编程模型入口。官方硬性要求**三条线**都带
# x-opencode-session(缺失直接 400 MissingSessionID),并建议用专属 UA
# 而非通用库名(实测 UA 不敏感,会话头才是必需)。适配器据此开关在
# 每次请求动态注入会话头(不能放静态 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-21 更新**:按上游 `GET /models`(35 个)+ 官方文档表刷新 —— 新增 7 个
# (deepseek-flash / grok-4.7 / omen-alpha / gpt-6-luna / mimo-v2.6-flash /
# mimo-v2.6-pro / space-bunny-free),下线 1 个(union-alpha),**免费模型标注在
# display_name 里带「(免费)」**(当前只有 space-bunny-free)。
# 实测口径(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 Chat Completions 线 ────────────────────────
- id: "glm-5.3-flash"
display_name: "GLM-5.3-Flash"
type: "text"
context_window: 1000000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 131072 # 最大输出(token)
protocols: ["chat/completions"]
- id: "glm-5.3"
display_name: "GLM-5.3"
type: "text"
context_window: 1000000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 131072 # 最大输出(token)
protocols: ["chat/completions"]
- id: "glm-5.2"
display_name: "GLM-5.2"
type: "text"
context_window: 1000000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 131072 # 最大输出(token)
protocols: ["chat/completions"]
- id: "kimi-k2.7-code"
display_name: "Kimi K2.7 Code"
type: "text"
context_window: 262144 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 262144 # 最大输出(token)
protocols: ["chat/completions"]
# 上游硬约束:该模型**只接受 temperature=1**,传 0 / 0.7 等一律 400
# "invalid temperature: only 1 is allowed for this model"。
# 写死后网关无论收到什么温度都按 1 发(前端温度滑块、API 传参、一键测速探针
# 统一生效);客户端不传 temperature 时也会显式按 1 发送,与上游默认值一致。
params:
temperature: 1
- id: "longcat-2.0"
display_name: "LongCat 2.0"
type: "text"
context_window: 1000000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 131072 # 最大输出(token)
protocols: ["chat/completions"]
- id: "mimo-v2.5"
display_name: "MiMo V2.5"
type: "text"
context_window: 1000000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 128000 # 最大输出(token)
protocols: ["chat/completions"]
- id: "mimo-v2.5-pro"
display_name: "MiMo V2.5 Pro"
type: "text"
context_window: 1048576 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 128000 # 最大输出(token)
protocols: ["chat/completions"]
- id: "hy4-preview"
display_name: "Hy4 Preview"
type: "text"
context_window: 1024000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 64000 # 最大输出(token)
protocols: ["chat/completions"]
- id: "hy3"
display_name: "Hy3"
type: "text"
context_window: 256000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 128000 # 最大输出(token)
protocols: ["chat/completions"]
# ── 2026-09-21 按上游 /models + 官方文档表补录 ──────────
- id: "mimo-v2.6-flash"
display_name: "MiMo V2.6 Flash"
type: "text"
context_window: 1048576 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 131072 # 最大输出(token)
# 实测:chat 200;messages / responses 都是 503「Endpoint is unavailable」
protocols: ["chat/completions"]
- id: "mimo-v2.6-pro"
display_name: "MiMo V2.6 Pro"
type: "text"
context_window: 1048576 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 131072 # 最大输出(token)
protocols: ["chat/completions"]
# ── Chat + Messages 两条线都实测可用 ─────────────────
- id: "kimi-k3"
display_name: "Kimi K3"
type: "text"
context_window: 1048576 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 131072 # 最大输出(token)
protocols: ["chat/completions", "messages"]
- id: "minimax-m3"
display_name: "MiniMax M3"
type: "text"
context_window: 512000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 128000 # 最大输出(token)
protocols: ["chat/completions", "messages"]
- id: "qwen3.8-max"
display_name: "Qwen3.8 Max"
type: "text"
context_window: 262144 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 131072 # 最大输出(token)
protocols: ["chat/completions", "messages"]
- id: "qwen3.8-flash"
display_name: "Qwen3.8 Flash"
type: "text"
context_window: 1000000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 131072 # 最大输出(token)
protocols: ["chat/completions", "messages"]
- id: "qwen3.7-plus"
display_name: "Qwen3.7 Plus"
type: "text"
context_window: 1000000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 65536 # 最大输出(token)
protocols: ["chat/completions", "messages"]
# ── 三条线全通(实测 chat / messages / responses 均 200,
# 非文档线另经流式 + 工具调用复核) ────────────────
- id: "deepseek-v4.1-flash"
display_name: "DeepSeek V4.1 Flash"
type: "text"
context_window: 1000000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 384000 # 最大输出(token)
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"
context_window: 1000000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 384000 # 最大输出(token)
protocols: ["chat/completions", "messages", "responses"]
# ── Anthropic Messages 线(文档主推这条)─────────────
# ── OpenAI Responses 线 ───────────────────────────────
- id: "grok-4.7"
display_name: "Grok 4.7"
type: "text"
context_window: 500000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 500000 # 最大输出(token)
# 2026-09-21 新增;实测 responses 200,chat / messages 都是 503「Endpoint is unavailable」
protocols: ["responses"]
- id: "gpt-5.6-luna"
display_name: "GPT 5.6 Luna"
type: "text"
context_window: 1050000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 128000 # 最大输出(token)
protocols: ["responses"]
- id: "gpt-6-luna"
display_name: "GPT 6 Luna"
type: "text"
context_window: 1050000 # 第三十三轮(2026-09-24):上下文窗口(token),每日同步维护
max_output_tokens: 128000 # 最大输出(token)
# 2026-09-21 新增;实测 responses 200(官方文档表同样标 responses)
protocols: ["responses"]
# 2026-09-27 自动同步:官方文档新增(scripts/sync_models.py)
# 2026-10-07 自动同步:官方文档新增(scripts/sync_models.py)
# 2026-10-08 自动同步:官方文档新增(scripts/sync_models.py)
- id: "claude-haiku-5-5"
display_name: "Claude Haiku 5 5"
type: "text"
context_window: 1000000 # 同步 2026-10-09(scripts/sync_models.py)
max_output_tokens: 128000 # 同步 2026-10-09(scripts/sync_models.py)
# 协议线取自官方 Endpoints 表,未逐线实测(现网其它模型是实测过的)
protocols: ["messages"]
# 2026-10-21 自动同步:官方文档新增(scripts/sync_models.py)
# 2026-10-21 自动同步:官方文档新增(scripts/sync_models.py)
# 2026-10-21 自动同步:官方文档新增(scripts/sync_models.py)
- id: "step-5-preview"
display_name: "Step 5 Preview"
type: "text"
context_window: 1000000 # 同步 2026-10-21(scripts/sync_models.py)
max_output_tokens: 65536 # 同步 2026-10-21(scripts/sync_models.py)
# 协议线取自官方 Endpoints 表,未逐线实测(现网其它模型是实测过的)
protocols: ["chat/completions"]
# 2026-10-23 自动同步:官方文档新增(scripts/sync_models.py)
- id: "minimax-m3.1-flash"
display_name: "Minimax M3.1 Flash"
type: "text"
context_window: 1000000 # 同步 2026-10-24(scripts/sync_models.py)
max_output_tokens: 512000 # 同步 2026-10-24(scripts/sync_models.py)
# 协议线取自官方 Endpoints 表,未逐线实测(现网其它模型是实测过的)
protocols: ["chat/completions"]
# 2026-10-24 自动同步:官方文档新增(scripts/sync_models.py)
- id: "kimi-k3.1-pro"
display_name: "Kimi K3.1 Pro"
type: "text"
context_window: 1048576 # 同步 2026-10-25(scripts/sync_models.py)
max_output_tokens: 131072 # 同步 2026-10-25(scripts/sync_models.py)
# 协议线取自官方 Endpoints 表,未逐线实测(现网其它模型是实测过的)
protocols: ["chat/completions"]
# 2026-10-27 自动同步:官方文档新增(scripts/sync_models.py)
- id: "iceman-contributor-free"
display_name: "Iceman Contributor Free"
type: "text"
context_window: 262144 # 同步 2026-10-28(scripts/sync_models.py)
max_output_tokens: 131072 # 同步 2026-10-28(scripts/sync_models.py)
# 协议线取自官方 Endpoints 表,未逐线实测(现网其它模型是实测过的)
protocols: ["chat/completions"]
free: true # 官方价格表标 Free
# 2026-10-09 自动同步:官方文档新增(scripts/sync_models.py)
# ── Dots AI(小红书 Dots Studio,第三十六轮新增)──────────────
# 官方文档:https://dots.ai/platform/docs(2026-09-28 通读)
# · 基础地址 https://note3-prev-api.askdiandian.com,两条线:
# POST /v1/chat/completions(OpenAI 兼容)/ POST /v1/messages(Anthropic 兼容)
# · 鉴权是**自定义头 `api-key: <KEY>`** —— 既不是 Authorization: Bearer,也不是
# x-api-key,所以第三十六轮给网关**新增了 `api-key` 这种鉴权样式**(config.AUTH_STYLES)。
# · /v1/messages 还需固定头 anthropic-version: 2023-06-01(官方示例里带)。
# · 官方限流按**单个 API Key** 计:60 次/分钟、1,500,000 Tokens/分钟 → 这里取 1 QPS
# (网关限流桶就是按 Key 分的,语义一致)。
dots:
name: "Dots AI(小红书)"
base_url: "https://note3-prev-api.askdiandian.com/v1"
auth:
token_env: "DOTS_API_KEY"
rate_limit_rps: 1.0 # 官方 60 次/分钟(按单个 Key)
endpoints:
chat/completions:
path: "/chat/completions"
auth: "api-key"
messages:
path: "/messages"
auth: "api-key"
headers:
anthropic-version: "2023-06-01"
models:
# 目前官方只有这一个模型(模型定价表里仅此一行)。
# 上下文窗口 512K 是官方文档明写的:`dots3-note-prev 的上下文窗口上限为 524,288 Token`,
# 且「输入 + max_tokens ≤ 该上限」。
- id: "dots3-note-prev"
display_name: "Dots3 Note Prev(免费体验)"
type: "text"
vision: true # 官方支持图片/视频/音频输入(示例见文档)
free: true # 官方定价表标「免费体验」,恢复收费前会提前告知
protocols: ["chat/completions", "messages"]
context_window: 524288 # 官方文档明确 512K
# max_output_tokens 官方未给上限("省略时由服务端默认策略决定")→ 留空不猜
# ── 虚拟模型 id(别名,第三十一轮)──────────────────────────
# 客户端固定写 model: wjd,实际转发到哪个真实模型由**管理员在模型页选**(也可以改这里)。
# · 只走 chat/completions(OpenAI)格式:用 /v1/messages、/v1/responses 打 wjd 会在入口
# 400 指路(网关不做跨格式转换)→ 所以 target 必须是**文本模型且支持 chat/completions**
# (页面上其余候选项置灰,服务端保存时同样拦)。
# · 别名不复制目标的配置:协议线、视觉、强制参数、定价**全继承 target**(一份事实来源)。
# · 别名不是模型:进 /v1/models(带 alias_of)但不进测速、不进模型计数、不进成本指标
# —— 那三项一律记**真实模型**。
# · enabled: false = 这个 id 不存在(等同没配);停用时后端不校验 target。
# · 别名 id 不得与真实模型 id 重名;简写 `wjd: opencode/kimi-k3` 等价于只填 target。
aliases:
wjd:
enabled: true
target: deepseek-v4.1-flash
note: 老板的固定入口(默认指向旗舰,随时可在模型页改)
server:
host: "127.0.0.1"
port: 8808
timeout: 120
retry: 3 # 同一模型的重试次数(含首次)。第二十七轮: 路由别名已删除,无 route.retry
# ── 运维开关 ──
health_auth: false # /health/* 是否也需鉴权(默认否,留给探活)
hot_reload: true # 监听 gateway.yaml mtime 自动重载(改配置免重启)
hot_reload_interval: 15 # 重载检查间隔(秒)
metrics_enabled: true # 记录调用指标(/metrics)
rate_limit_rps: 20 # 全局单 user QPS 上限(2026-10-23 由 null 改为 20:防泄露 Key 打爆额度;
# 供应商级限流仍由 provider.rate_limit_rps 控制,两者取更严的那个)
# 请求体字节上限。2026-09-24 从 2MB 提到 20MB:带图对话(生成/上传的 PNG 以
# base64 内联进历史,单张 100KB~750KB)几张就顶爆 2MB → 上游 413
# 「请求体超过上限 2000000 字节」。内部网关 + nginx 两层把关,保留限制只调大数字。
max_body_size: 20000000
cors_origins: ["*"] # CORS 允许来源(生产收紧为具体域名)
graceful_shutdown: 30 # 优雅关闭等待在途请求的秒数
# ── 防滥用 / 安全 ──
batch_max_concurrency: 16 # /batch 并发上限(客户端 max_concurrency 会被钳到此值)
batch_max_items: 64 # /batch 单次最大条目数(超出返回 400)
webhook_allow_private: false # 视频 callback_url 是否允许指向内网/回环(SSRF 防护,默认禁)
docs_enabled: false # FastAPI 文档(/docs、/openapi.json)是否开放(安全默认关)
auth_fail_limit_per_min: 20 # 同一来源 IP 每分钟鉴权失败上限,超过 → 429(防暴力枚举)
# ── 供应商熔断(Circuit Breaker) ──────────────────────
# 某供应商连续/滑动窗口失败达到 failure_threshold 就熔断 cooldown 秒,
# 期间直接跳过(不再白等),让 fallback 快速切到健康供应商。
circuit:
enabled: true
failure_threshold: 3 # 连续失败 3 次即熔断
cooldown: 30 # 熔断持续 30 秒
window: 10 # 滑动窗口
# ── 可观测性 ───────────────────────────────────────────
observability:
log_level: "INFO"
log_json: false # true = 结构化 JSON 行日志(接 ELK/CloudWatch)
access_log_maxlen: 500 # 访问日志环形缓冲长度
# ── 定价(用于 /v1 响应里估算成本,人民币/百万 token) ─
# 不配则该模型 estimated_cost_cny 不返回(不影响调用)。
pricing:
per_model:
agnes-3.0-flash: { input: 0, output: 0 } # 同步 2026-09-24(原 0.35/1;文档现价 ¥0/M 输入、¥0/M 输出)
agnes-2.5-flash: { input: 0, output: 0 } # 文档现价暂免(输入/输出/缓存命中均 ¥0/百万)
agnes-2.5-pro: { input: 3, output: 6 } # 2026-09-24 自动同步(文档现价)
agnes-2.5-pro-beta: { input: 3, output: 6 } # 2026-10-21 自动同步(文档现价)
# ── 媒体下载代理白名单(第十七轮)────────────────────────
# 生成的图片/视频挂在第三方 CDN 上且不带 CORS 头,浏览器里既 fetch 不到 blob、
# 跨域 <a download> 也不生效(只会打开新标签页)。所以由网关代拉一次并加上
# Content-Disposition: attachment,前端「下载」按钮才真的能存文件。
# 安全:这是网关唯一一个服务端主动出网的接口 —— 只有这里列出的域名(含其子域)
# 允许被代下载,且解析出来的 IP 必须是公网地址;列表为空 = 该功能整体关闭。
# 换了供应商/换了 CDN 域名时,往这里加一条即可。
download:
# 维护提醒(第三十轮):这张表是**下载代理的出网白名单** —— /v1/media/download 只肯代抓这里列出的域名。
# 供应商换 CDN、或同一供应商多套存储(普通版 / 水印版)时,**漏加就会让「下载」按钮 400**
# (报「该地址不在允许下载的域名白名单内」)。新增前先确认域名确实属于该供应商的产物存储。
allowed_hosts:
- "cos-platform-outputs.agnes-ai.cn" # Agnes 图像/视频产物 CDN(普通版)
- "maas-watermark-prod-new.cn-wlcb.ufileos.com" # Agnes 水印版产物 CDN(UCloud ufileos)
max_bytes: 67108864 # 单文件上限 64MB
# ── 网关入口鉴权 ─────────────────────────────────────
# 账号与 API Key 全部由页面管理,存在 data/users.json(见 app/users.py):
# 管理员在「用户管理」页建账号,各账号在「设置 → 我的 API Key」自助铸 Key。
# 本文件里**不再有任何用户/密钥**,只有一个运维开关:
# auth.session_ttl_minutes —— 网页登录签发的会话有效期(分钟,默认 1440 = 24h)
# 第十八轮: 删掉了这里残留的旧 `auth.enabled/users/key` 死配置(含一把明文 wjd- Key)。
# 那些键早已不再被 config.py 读取(只读 session_ttl_minutes),
# 那把 Key 在 users.json 里也不存在 → 认不了任何入口,但会让"yaml 里没有明文凭证"的说法失真。
auth:
session_ttl_minutes: 1440
# ── 路由别名 / fallback 链:已整体删除 ──────────────────
# 第二十七轮(老板 2026-09-18 决策):**路由别名功能整体删除**,不再有 routes 段。
# 原因:三线直传落地后"入站格式 = 出站格式",模型 id 必须与协议线一一对应;
# 再套一层"自动挑最快模型"的别名,会把调用方选定的格式/能力(视觉、工具、协议线)
# 悄悄换掉。现在调用方直接填真实模型 id;要换模型就换 id,网关不再替谁做主。
# 老配置里残留的 routes 段会被忽略(不会让进程起不来),日志里有 warning 可查。
# 一键测速(Models 页每个模型后面的)不受影响,仍然逐个模型实测延迟。