官方把文档的 `## Endpoints` 表改成「看 console 页 / 用 models 接口」, HTML 里不再有带 opencode.ai/ 地址的模型行,fetch_opencode() 的 <tr>/<td> 解析拿不到任何行 → 自动化日报「模型清单同步」整块失败: [2026-11-17 23:02:18] exit=2 RuntimeError: OpenCode 文档没解析出 Endpoints 表 [2026-11-18 23:02:29] exit=2 同上 改为优先读官方 models 接口(实测无需鉴权): GET https://opencode.ai/inference/go/v1/models (zen/go/v1/models 同源同内容) 每条自带 id/name/type/api{chat-completions,responses,messages,generate-content}/ recommended_api/limit{context,output}/cost.text.*.price/go.limited_regions, 据此推导协议线、免费标记与地区限制;HTML 表解析降级为兜底(接口不可用才走)。 首次落盘: - 删除 opencode/mimo-v2.5、mimo-v2.5-pro(上游已被 V2.6 取代) - 上下文 hy4-flash-free → 1048576/65536;qwen4-max → 1000000/262144 - 跳过 gemini-4-argon(仅 generate-content)、beam-free 与 muse-spark-1.2/1.3(地区限制) 验证:落盘后 28 个模型、/healthz 200、hot_reload 自动生效未重启、重跑「无漂移」; sync_onemin.py 同步通过(49 接口 / 43 配置 / 跳过重名 6)。 顺带把运行时的 data/ban_history.jsonl 加进 .gitignore(含被封 IP,属隐私)。
679 lines
36 KiB
YAML
679 lines
36 KiB
YAML
# 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"
|
||
# 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 输出
|
||
# 2026-11-09 自动同步:官方文档新增(scripts/sync_models.py)
|
||
- id: "agnes-2.5-pro-theta"
|
||
display_name: "Agnes 2.5 Pro Theta"
|
||
type: "text"
|
||
# 文档现价 ¥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"
|
||
rate_limit_rps: 3.0 # 2026-11-06 新增:主动限流,避免被上游 429
|
||
# ── 模型 ─────────────────────────────────────────────────
|
||
# 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: "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: 1048576 # 最大输出(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: 1048576 # 同步 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-11-06 自动同步:官方文档新增(scripts/sync_models.py)
|
||
- id: "hy4"
|
||
display_name: "Hy4"
|
||
type: "text"
|
||
context_window: 1048576 # 同步 2026-11-07(scripts/sync_models.py)
|
||
max_output_tokens: 65536 # 同步 2026-11-07(scripts/sync_models.py)
|
||
# 协议线取自官方 Endpoints 表,未逐线实测(现网其它模型是实测过的)
|
||
protocols: ["chat/completions"]
|
||
# 2026-11-07 自动同步:官方文档新增(scripts/sync_models.py)
|
||
# 2026-11-10 自动同步:官方文档新增(scripts/sync_models.py)
|
||
- id: "longcat-2.5-free"
|
||
display_name: "Longcat 2.5 Free"
|
||
type: "text"
|
||
context_window: 1000000 # 同步 2026-11-10(scripts/sync_models.py)
|
||
max_output_tokens: 262144 # 同步 2026-11-10(scripts/sync_models.py)
|
||
# 协议线取自官方 Endpoints 表,未逐线实测(现网其它模型是实测过的)
|
||
protocols: ["chat/completions"]
|
||
free: true # 官方价格表标 Free
|
||
# 2026-11-16 自动同步:官方文档新增(scripts/sync_models.py)
|
||
- id: "hy4-flash-free"
|
||
display_name: "Hy4 Flash Free"
|
||
type: "text"
|
||
context_window: 1048576 # 同步 2026-11-19(scripts/sync_models.py)
|
||
max_output_tokens: 65536 # 同步 2026-11-19(scripts/sync_models.py)
|
||
# 协议线取自官方 Endpoints 表,未逐线实测(现网其它模型是实测过的)
|
||
protocols: ["chat/completions"]
|
||
free: true # 官方价格表标 Free
|
||
# 2026-11-16 自动同步:官方文档新增(scripts/sync_models.py)
|
||
- id: "qwen4-max"
|
||
display_name: "Qwen4 Max"
|
||
type: "text"
|
||
context_window: 1000000 # 同步 2026-11-19(scripts/sync_models.py)
|
||
max_output_tokens: 262144 # 同步 2026-11-19(scripts/sync_models.py)
|
||
# 协议线取自官方 Endpoints 表,未逐线实测(现网其它模型是实测过的)
|
||
protocols: ["messages"]
|
||
# 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: 50 # 全局单 user QPS 上限(2026-11-06 由 20 改为 50:多客户端并发时 20 太紧)(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 允许来源(2026-11-06 由 ["*"] 收紧为白名单)
|
||
- "https://api.wangjinding.com"
|
||
- "http://127.0.0.1:8808"
|
||
- "http://localhost:8808"
|
||
- "http://127.0.0.1:5173" # Vite dev server
|
||
- "http://localhost:5173"
|
||
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: 60 # 同一来源 IP 每分钟鉴权失败上限(2026-11-06 由 20 改为 60:客户端配错 Key 重试容易误触发),超过 → 429(防暴力枚举)
|
||
auth_fail_ban_seconds: 3600 # 2026-11-06 新增:鉴权失败超限后拉黑 1 小时(0=只限流不拉黑)
|
||
|
||
# ── 供应商熔断(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: 0.7, output: 2.1 } # 2026-10-21 自动同步(文档现价)
|
||
agnes-2.5-pro-theta: { input: 0.7, output: 2 } # 2026-11-09 自动同步(文档现价)
|
||
|
||
# ── 媒体下载代理白名单(第十七轮)────────────────────────
|
||
# 生成的图片/视频挂在第三方 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 页每个模型后面的)不受影响,仍然逐个模型实测延迟。
|