SipengXie2024
77ba3346d1
fix(openai): skip foreign-vendor models on ChatGPT OAuth accounts, passthrough included
...
Empty-mapping OpenAI OAuth accounts accepted claude-* models, and OAuth or
setup-token accounts with openai_passthrough accepted every model. Both send
requests to chatgpt.com/backend-api/codex, which answers foreign models with
a non-retryable 400 ("not supported when using Codex with a ChatGPT
account"), so mixed groups handed claude-* requests from Codex clients to
the OAuth account instead of the API-key account that serves them.
- Add "claude-" to openAIOAuthForeignModelPrefixes.
- Apply the foreign-prefix check to OAuth and setup-token passthrough too;
API-key passthrough keeps allowing every model.
- Schedule /v1/messages by the channel-mapped model, as Responses, Chat
Completions and the Responses WebSocket already do, so a channel mapping
a claude-* alias to a GPT model still lands on OAuth accounts.
2026-11-17 09:50:16 +00:00
shaw
42efee245e
Merge remote-tracking branch 'gh/main' into fix-8748
2026-11-16 19:22:51 +08:00
shaw
7f3fe5bfde
Merge main into perf/scheduler-snapshot-coalesce
...
Resolve conflicts with #8729 , which caches the configured account pool
and checks time-based blocks (rate limit, overload, temp-unschedulable)
on every read:
- readSnapshotAccounts filters by IsSchedulable on both the
GetSnapshotValues path (in-place compaction of the caller-owned slice)
and the GetSnapshot path.
- The coalesced DB fallback still publishes the full configured pool.
Each caller's private copy contains only accounts that are
schedulable now.
- The fallback test stubs now implement ListModelAvailabilityCandidates,
which #8729 switched the DB fallback to. Values-reader fixtures are
marked schedulable. Adds tests for time-blocked filtering on both paths
and for publishing the full pool.
2026-11-16 17:18:20 +08:00
feeeei
9c32800986
perf(scheduler): 调度快照加载与数据库回源按 bucket 合并,减少大分组选号的整组复制
...
分组账号数多时,进程内快照条目失效后每个并发请求各自 ZRANGE + MGET 全部精简记录并
逐个解码;Redis 读失败时每个请求又各自回源数据库并回写整份快照。每次选号还要把整组
账号按值复制三遍,并分块串行 MGET 全部 last_used。
- 快照条目加载按 (bucket, active, 修订号) 合并为一次,加载与调用方取消解耦;
(active, 修订号) 未变、仅超过 10s 直接复用时长的条目在 20s 宽限期内先返回,
同时由一次后台加载刷新,修订号或 active 变化时仍等待新数据
- 重新加载时,精简记录原文未变且模型映射预解析对应当前运行时版本的账号沿用已解码母本
- last_used 读取结果在条目内复用 200ms,本进程写入 last_used 后立即失效;
多个分块的 MGET 放进同一个 pipeline 一次往返
- 新增 GetSnapshotValues 直接返回值切片,服务层优先使用,省掉 derefAccounts 的复制;
调度阈值过滤改为原地压缩
- 数据库回源按 bucket 合并:取发布令牌、读库与回写在一次共享调用里完成,
未配置 db_fallback_timeout_seconds 时上限 30s,各调用方得到独立的切片
压测(单用户 Bedrock、关闭在途预留):300 号 57.7K→61.6K RPM,500 号 42.3K→50.0K RPM。
2026-11-15 18:32:56 +08:00
Anankke
a0340d4dde
fix(websearch): honor account mode on every channel-toggle platform
...
GetWebSearchEmulationMode only read extra.web_search_emulation for anthropic and openai API key accounts and returned "default" for every other platform, although the channel form already lists zhipu, command_code, opencode_go and minimax for the same feature.
Those accounts reach shouldEmulateWebSearchFor through the OpenAI gateway /v1/messages path, so "enabled" was ignored and "disabled" could not override a channel that turns the emulation on.
Let every platform in the channel whitelist through the gate and extend the account and channel matrix test to them.
2026-11-14 04:10:41 -08:00
r266-tech
9d5fb150b9
feat(openai): optionally filter passthrough accounts by model
2026-11-13 12:14:06 +08:00
Wesley Liddick
a34f373973
Merge pull request #8251 from feeeei/perf/scheduler-snapshot-memo
...
perf(scheduler): 调度快照解码结果常驻进程内存,选号不再每次全量读取并解码分组
2026-10-21 17:44:14 +08:00
Wesley Liddick
b3e66f79a8
Merge pull request #8250 from feeeei/perf/model-mapping-signature
...
perf(account): 模型映射签名改为与遍历顺序无关、零分配
2026-10-21 17:44:03 +08:00
feeeei
53002f677c
perf(scheduler): 调度快照解码结果常驻进程内存
...
GetSnapshot 每次选号都 ZRANGE 全组账号 ID、分块 MGET 全组 sched:meta
并逐条 JSON 解码,Redis 出口、CPU 与 GC 都随分组号数线性增长。
- 每个 bucket 的解码结果常驻进程内存。每次读取用一次 MGET 取 ready、
active、全局修订号与 bucket 平台修订号(mixed 另加 antigravity),全部与
条目一致且条目未超过 10 秒才复用,否则重新加载。last_used 仍每次读取,
套用在本次调用独占的副本上,LRU 语义不变。
- 修订号是随机串:精简记录改写后写入所涉平台的修订号,与最后一批写入同一
pipeline 发出;删除记录、账号平台变化(SET ... GET 取回旧值比对)、
写入出错时写入全局修订号,出错路径在后台合并写入。
- 母本发布前预解析模型映射;副本在指针、长度与运行时版本都匹配时直接复用,
不计算签名。
- 未命中、空快照、记录缺失、解码失败、Redis 出错的返回与原实现一致;选中后
的整账号读取仍每次重新解码,转发路径对账号的原地修改不触及常驻对象。
真实 Redis 端到端(SelectAccountWithLoadAwareness,本机):
100 号:3.83ms → 0.73ms,Redis 出口 251KB → 7.0KB,分配 2.03MB → 0.23MB
1000 号:27.8ms → 1.92ms,Redis 出口 2.47MB → 25KB,分配 20.2MB → 1.97MB
每次都未命中:100 号 3.83ms → 3.10ms,1000 号 27.6ms → 21.9ms
常驻内存约为每号 7KB × 活跃 bucket 数;闲置超过 100 秒的条目在写入新
条目时清除。
2026-10-21 00:38:20 +08:00
feeeei
89654873ff
perf(account): 模型映射签名改为与遍历顺序无关、零分配
...
GetModelMapping 命中缓存前要计算 model_mapping 的签名:收集全部 key、
排序、再逐个写入 fnv64a。签名只存放在 Account 的未导出字段里,不持久化、
不序列化、不跨进程比较,排序的唯一作用是消除 Go map 的随机遍历顺序。
改为逐条目计算 FNV-1a(key、分隔字节、value 或非字符串标记)并经 fmix64
收尾后求和:内容相同签名相同,单条改值、改键、两个 key 互换 value 都能检出,
且不分配内存。30 条映射单次计算约 2.3µs/1 次分配降到约 0.8µs/0 次分配;
选号时每个候选账号每次调用 3 次。
2026-10-20 23:32:41 +08:00
feeeei
d6120b5d8e
feat(account): Vertex 账号支持配额上限
...
- 新增 AccountTypeSupportsQuota / SupportsAccountQuota(apikey/bedrock/service_account)
作为配额账号类型的唯一判定,累加、超限停调度、额度通知、接口输出与计费仓储统一改用;
池模式等其它特性仍只看 IsAPIKeyOrBedrock
- service_account 配额语义与 apikey 一致:配置了任一上限才累加,用满停调度,跨阈值发额度通知
- 计费事务中账号已删除时跳过账号配额计数,与 API Key 对称,用户扣费不再整笔回滚
- 账号额度通知只对配置了上限的账号做检查
- 前端创建/编辑弹窗对 Vertex 开放配额设置,设上限后用量列显示配额进度条;
账号类型判断收敛到 supportsAccountQuota
2026-10-19 23:31:46 +08:00
Wesley Liddick
b14f316ca2
Merge pull request #8080 from SipengXie2024/fix/openai-messages-web-search-emulation
...
fix(openai): emulate web_search on /v1/messages for OpenAI API key accounts
2026-10-16 12:27:52 +08:00
xugao
26aab6dc07
fix(openai): respect GPT-5.5 retirement on ChatGPT upstreams
2026-10-15 20:53:15 +08:00
shaw
9d3cc4507f
fix(antigravity): keep legacy default passthroughs and bill Claude 5.5 tier IDs at base rates
...
- Restore runtime default passthroughs and Gemini 3.1 Pro aliases for
explicit Antigravity model_mapping. Mappings saved before the Gemini
3.x Flash / 3.1 Pro releases still depend on them; dropping them would
silently remove those models from existing accounts on upgrade.
- Capability sync now skips injected-only passthrough targets, so models
the upstream catalog omits no longer mark the sync as partial.
- Price Antigravity claude-{opus,sonnet}-5-5-{high,medium,low} at the base
Opus/Sonnet 5.5 card instead of substring-matching claude-opus-5 /
claude-sonnet-4-5 (1.25x-3x overbilling).
2026-10-15 15:47:42 +08:00
Long Li
373d43533a
feat(antigravity): support Gemini 4 Argon and accurate upstream model catalogs
2026-10-15 02:06:23 +09:00
SipengXie2024
26e55cf332
fix(openai): emulate web_search on /v1/messages for OpenAI API Key accounts
...
Chat Completions conversion drops Anthropic web_search tools, so Claude
Code's WebSearch on OpenAI-platform groups (e.g. DeepSeek upstreams)
got no web_search_tool_result and reported 0 results. Run the existing
search emulation in ForwardAsAnthropic and let OpenAI API Key accounts
opt in via extra.web_search_emulation.
2026-10-14 07:02:52 +00:00
Wesley Liddick
49b2122dc6
Merge pull request #7991 from wucm667/fix/issue-7988-international-quota
...
fix(quota): recognize international coding endpoints
2026-10-13 15:00:31 +08:00
shaw
9d5e63a598
合并 main 并解决 PR #7828 的测试文件冲突
...
完整保留临时不可调度规则作用范围测试与 Gemini 显式缓存测试;保留双方生产代码改动。
2026-10-13 14:59:02 +08:00
feeeei
2588675ce7
fix(gemini): 第三方上游 API Key 与 Vertex 不再套用 AI Studio 等级和模拟配额
...
- 按 base_url 判定上游:非官方地址的 Gemini API Key 账号视为第三方上游
- 第三方上游与 Vertex 不返回本地模拟配额,隐藏等级与配额说明;
账号列表中第三方上游按普通 Key 账号展示今日统计与额度进度条,
Vertex 显示 vertex 徽章与今日统计
- 第三方上游的 429 只认显式重试时长,否则走全局 429 兜底冷却,
不按每日配额冷却到 PST 午夜
- 创建账号:第三方 Base URL 不显示 AI Studio 等级选项,也不写入 tier_id;
API 密钥卡片标题与说明不再限定 AI Studio,免费层说明只在官方 Base URL 下显示;
OAuth 等级回退下拉只在 OAuth 表单显示
2026-10-10 23:37:48 +08:00
wucm667
ce6242fca1
fix(quota): recognize international coding endpoints
2026-10-10 14:47:11 +08:00
SavitarC and Claude Opus 5.5
874871a25a
feat(platform): 接入 Cline 平台
...
Cline API(https://api.cline.bot/api/v1)是 OpenAI 兼容的多模型聚合端点,
只提供 Chat Completions(Cline 自己的客户端同样只走该端点),模型名带厂商
前缀。同一个 API Key 下有两个互不影响的额度来源,由模型名决定扣哪一边:
cline-pass/* 走 ClinePass 订阅(5 小时 / 7 天 / 30 天滚动上限),其余付费
模型扣账户积分;cline-free/* 免费模型只有逐模型的每日额度。
转发:
- 平台清单与 provider profile 新增 cline:按入站协议分流,只登记 Chat
Completions 端点,Responses / Anthropic 入站由现有转换链转为 Chat
Completions,无需新增转发代码。
- 只有一个接入模式,不需要选择账号类型。
- 连接测试未指定模型时使用 profile 默认模型(固定 Chat Completions 的账号
此前落到不带厂商前缀的通用默认模型);订阅了 ClinePass 的账号改用订阅
模型,不消耗积分,ClinePass 冷却中时仍用按量模型。
用量与余额:API Key 调 /api/v1/users/me/plan/usage-limits(三档窗口的已用
百分比与重置时间,未订阅时 404)与 /api/v1/users/me、/users/{id}/balance
(余额单位为百万分之一积分,1 积分 = 1 美元),兼容 {success, data} 信封,
只查官方主机。复用额度探测与周期检测:账号列表显示 ClinePass 窗口与积分
余额;窗口用满时 ClinePass 模型冷却到重置时间,未订阅时不调度 ClinePass
模型,积分低于阈值时冷却付费模型;数据显示恢复后自动解除,但只解除探测能
证明已恢复的原因(窗口用满、未订阅、积分不足),组织账户、所需订阅档位、推理
额度与花费上限的冷却到期后由请求重新确认。周期检测中走账号接口探测的平台
改为登记表(平台、支持判定、检测函数一一对应),按账号所属平台分派。
上游错误(依据 docs.cline.bot/api/errors 与 Cline 客户端的错误分类,按文案
识别):积分不足(含其他 402)、组织花费上限、推理额度上限、ClinePass 超限、
未订阅 ClinePass / 组织账户、免费模型每日额度。两边的超限只冷却请求模型所属
的一边(模型级冷却键 cline:pass / cline:credits,调度按请求模型检查),不停
整个账号;免费模型只限该模型,冷却到文案中的 "try again in …"。ClinePass
超限冷却到快照中对应窗口的重置时间,没有快照时 5 小时窗口 1 小时、7 天
6 小时、30 天 24 小时。普通频率限制走默认 429 逻辑。402 的冷却写入失败时
也不落入默认分支永久置 error(探测只覆盖激活账号,置 error 后无法自动恢复)。
余额类冷却时长抽为 cnBalanceCheckCooldown 共用。
上游计费探测的官方域名加入 cline.bot。
前端:官方标志(机器人头像)、violet 配色(品牌紫)、复用额度与余额单元格
(同样只对官方主机上的 API Key 账号显示);接入模式展示名抽为共用函数,编辑
弹窗不再显示原始模式值。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com >
2026-10-09 10:11:06 +08:00
SavitarC and Claude Opus 5.5
e2939cd8fa
feat(platform): 接入 Command Code 平台
...
转发:
- 平台清单与 provider profile 新增 command_code:按模型分流,Chat
Completions / Responses 基址 https://api.commandcode.ai/provider/v1 ,
Anthropic 基址 https://api.commandcode.ai/provider;内置规则 claude-* →
Anthropic、gpt-* → Responses(也支持 Chat Completions)。
- 原生 Anthropic 端点的版本感知拼接改按分流方式判断,转发与连接测试共用
(Anthropic 基址带 /v1 时连接测试不再误报为配置错误)。
按模型的协议集合(模型支持入站协议时直通,免去协议转换):
- 分流规则可带协议集合 protocols(首项为首选协议):入站协议在集合中时同
协议直通,否则走首选协议;只有一个协议时与原规则相同,OpenCode 行为不变。
- profile 新增 model_catalog:Command Code 的 /models 为每个模型给出
supported_endpoints。官方默认地址的目录按地址全进程共享,自定义上游按账号
隔离;目录请求的 UA 收敛与账号请求头覆写与转发一致。目录缓存 30 分钟、后台
刷新,失败退避 5 分钟;从未加载成功时首批请求最多等 2 秒,冷启动也按目录
分流。账号规则未命中的模型按目录取协议集合;目录不可用时回落内置规则(账号
未配置规则时)或 Chat Completions。
- 三个入站入口共用的 resolveUpstreamProtocol 增加目录参数。
- 前端分流规则编辑器可为每条规则勾选"也支持"的协议;提供模型目录的平台,
兜底行改为说明按上游模型列表选协议。
连接测试:
- 按模型分流的平台共用一条测试路径(协议与网关同一判定,含模型目录;默认
测试模型取自 profile),不再落入 Claude 测试路径。
- 首个分支由"国产厂商"改为"按入站协议分流";adaptive 测试跳过 profile 未
提供的 Anthropic 端点。现有国产厂商行为不变。
- 连接测试是 OpenCode 专属分流入口的最后一个调用方,改走统一判定后删除
ResolveOpenCodeGoUpstreamProtocol、openCodeGoNativeProtocol,以及此前就只剩
测试使用的 OpenCodeGoModelProtocol;路由矩阵的旧行为基准改为测试内独立复述。
额度与余额(/alpha/whoami、billing/credits、billing/subscriptions、
usage/summary):
- 额度探测写入 5 小时 / 每周窗口(限额套餐)与还原出的月度窗口,同时写入
积分余额;余额探测只取积分。仅对官方主机上的 API Key 账号生效。
- 订阅周期或本周期用量取数失败时保留上一次的月度快照,不当作没有月度窗口
清掉;窗口尚未开始(没有重置时间)时清掉上一个窗口的重置时间。
- whoami 取不到时探测整体失败,不按个人账户继续(组织账号会查到成员的个人
钱包,并据此按余额停调)。
- 阈值停调与定时检测纳入 Command Code;有充值积分时上游跳过窗口检查,窗口
快照不参与停调与冷却;积分低于余额阈值时临时停调。
- 上游计费探测的官方域名加入 commandcode.ai,不把 Key 发往官方主机上并不
存在的中转计费接口。
上游错误(依据 commandcode.ai/docs/troubleshooting/errors,按文案分类,
402 / 403 / 429 同样处理):
- 5 小时 / 每周窗口用满:带原因的临时停调,到文案中的 "Resets in …",解析
不出时回落额度快照;充值积分不受窗口限制,额度 / 余额探测发现充值积分后
只解除这一类停调。
- 积分耗尽(含 usage_exceeded):可恢复的临时停调,积分恢复后由周期检测
解除,不再永久置为 error。
- 组织花费上限:文案指明模型("set for <模型>")且请求模型已知时只写模型级
限流;成员总额度或作用域不明时整个账号冷却,最长一小时。
- 普通频率限制走默认 429 逻辑,不再冷却到窗口重置点。
前端:
- 账号列表显示额度窗口与积分余额,阈值设置增加 command_code。单元格可见性
改为按账号判定,与后端一致:只对官方主机上的 API Key 账号显示,自定义中转
显示占位符,不再每次打开列表都探测出一行报错。
- 使用官网的官方标志(圆角方块内镂空 ⌘);配色为中性灰(品牌黑色已由
Grok 使用)。
测试基准中原先用作"仅服务端登记"示例的 command_code 改为虚构的 acme_router;
新增的前端测试加入 CI 前端关键测试列表。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com >
2026-10-09 10:11:05 +08:00
SavitarC and Claude Opus 5.5
3b89cc08dd
refactor(platform): 后端平台列表改由平台清单派生
...
新增 domain/platforms.go 作为具体平台的单一数据来源:每个平台一条登记,
写明展示名、所走网关(anthropic / openai / gemini / antigravity)、是否国产
单一厂商、定价目录 provider 名,顺序即展示顺序。
以下列表与判断改为查平台清单:
- "全部具体平台":用户平台额度白名单、错误透传规则平台列表、组合路由目标
校验、上游计费探测资格、调度快照遍历、组合分组的定价 / 模型映射回退、
组合分组默认模型列表;
- "OpenAI 网关族":IsOpenAICompatible、NormalizeOpenAICompatiblePlatform、
Responses 兼容路由判断、count_tokens 分发、组合分组的 OpenAI 文本目标;
- 国产厂商判断、渠道定价同步的 provider 映射;
- 多协议 API Key 供应商相关的请求头覆盖资格、凭证测试、OpenAI 基址回退改用
IsMultiProtocolAPIKeyProvider;
- 分组平台与组合路由目标的请求校验改为自定义校验标签 group_platform /
concrete_platform,拒绝规则不变(大小写、首尾空格、别名一律拒绝)。
组合分组的逐平台回退是先命中者生效,CompositePrecedencePlatformIDs 保持
原有顺序 anthropic、gemini、openai,其余按登记顺序追加。依赖具体实现的
能力(OAuth、渠道监控、调度阈值、余额 / 用量窗口、Codex 模型目录等)仍在
各自代码中显式列出。
等价性测试把改动前的每个列表与 switch 原样保留为基准,逐一比较派生结果
(含顺序),谓词覆盖全部平台、composite 与非法值 × 全部账号类型。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com >
2026-10-09 10:10:33 +08:00
SavitarC and Claude Opus 5.5
8ac2936a3d
refactor(gateway): 三个入站入口的上游协议分流收敛为 resolveUpstreamProtocol
...
此前 /v1/responses、/v1/chat/completions、/v1/messages 各自用一串 if 决定
上游协议:OpenCode 按模型规则、国产 adaptive 按入站、显式 api_protocol、
Responses 探针四个来源的优先级靠语句先后隐式决定,且每个入口都有
IsOpenCodeGo 特判。
- provider profile 新增 Routing(by_inbound / by_model),OpenCode 登记为
by_model;routesByModel 取代转发路径与 GetAPIProtocol 默认值中的
IsOpenCodeGo 判断。
- 新增 upstream_protocol_routing.go:resolveUpstreamProtocol 以单一函数给出
上游协议(按模型分流 → adaptive 按入站 → 显式 anthropic → CC 直转条件
→ Responses),resolveModelRoutedProtocol 以 profile 规则泛化 OpenCode
的规则解析;三个入口改为 switch 该结果选择既有转换路径,Responses 形状
请求体的转换合并为 convertResponsesShapedChatBody。
转换函数本身不变。新增分流矩阵测试经真实入口遍历 平台 × api_protocol ×
探针 × 账号类型 × 接入模式 × protocol_rules × 入站 × 模型(2045 组),
与改动前逐条 diff 仅 6 条不同:智谱 adaptive 的非 API Key 账号(UI 无法
创建)在 /v1/responses 入站时由 Responses 改为回落 CC,与
/v1/chat/completions 入口一致;这 6 组前后都在发出上游请求前报错。
协议规则与映射模型相关的类型、函数已被所有按模型分流的供应商共用,同时去掉
OpenCode 前缀(OpenCodeGoProtocolRule → ProtocolRule、matchOpenCodeGoProtocolRules
→ matchProtocolRules、NormalizeOpenCodeGoProtocolRulesCredentials →
NormalizeProtocolRulesCredentials、resolveOpenCodeGoMappedModel →
resolveMappedUpstreamModel 等),并删除收敛后已无调用方的
defaultOpenCodeProtocolRules。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com >
2026-10-09 10:10:32 +08:00
SavitarC and Claude Opus 5.5
3f8eea0807
refactor(provider): profile 端点改为按协议登记,Responses 路径约定并入 profile
...
ProviderEndpoints 由 ChatBaseURL + AnthropicBaseURL 改为以协议为键的
BaseURLs(chat_completions / responses / anthropic),与账号凭证
api_base_urls、前端 defaultCNAdaptiveBaseUrls 的结构一致:
- 某协议没有条目即表示不提供该原生端点,SupportsNativeCNResponses 改为
由 responses 条目推导,去掉单独的 NativeResponses 布尔值;
- DeepSeek 的 Responses 路径例外(/responses,无 /v1)从
buildOpenAIResponsesURLForPlatform 的平台硬编码移入 profile.ResponsesPath。
运行时行为不变。唯一的函数级差异:智谱 adaptive 账号的
GetCNProtocolBaseURL(responses) 默认值由 CC 基址变为空串;所有运行时调用方
均先经 UsesNativeCNResponses / SupportsNativeCNResponses 守卫,智谱不会走到,
TestAdaptiveProtocolBaseURLs 的对应期望随之更新。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com >
2026-10-09 09:17:41 +08:00
SavitarC and Claude Opus 5.5
c063a4016e
refactor(provider): 以 provider profile 收敛多协议供应商默认端点表
...
多协议 API Key 供应商(kimi/zhipu/deepseek/minimax/opencode_go)的默认端点
此前在 account.go 的 GetOpenAIBaseURL / defaultCNProtocolBaseURL /
GetAnthropicProtocolBaseURL / GetOpenAIFormatBaseURL 中按平台 switch 重复了
四遍,Responses 能力与 OpenCode 内置分流表也各自散落。
新增 provider_profile.go 作为单一数据来源:每个供应商登记各接入模式的
Chat/Anthropic 默认基址、内置 protocol_rules 与原生 Responses 能力;
上述函数、SupportsNativeCNResponses、IsMultiProtocolAPIKeyProvider 与
defaultOpenCodeProtocolRules 改为查表。纯重构,行为不变:新增测试以旧
switch 逻辑为基准,逐一核对平台 × account_mode × 协议的全部组合。
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com >
2026-10-09 09:17:41 +08:00
feeeei
5a25507dcb
feat(account): 临时不可调度规则新增作用范围 scope 选项
...
- 规则新增 scope 字段:account 命中后暂停整个账号,model 只冷却本次请求的模型;
字段缺省时保持现有语义(模型已知且非 401 走模型级,否则账号级),显式取值由运营人员决定,401 也不例外
- 模型未知的路径按账号级兜底;状态 JSON 记录 scope/model 便于排查
- 创建/编辑账号弹窗的规则编辑器新增作用范围单选卡片,新规则默认模型级;
未设置 scope 的存量规则按后端缺省语义回显(401 账号级、其余模型级),打开再保存不改变行为
2026-10-03 12:08:05 +08:00
shaw
9eb394e3e9
fix(typesafe): 堵住校验解析差异与审计盲区,收紧模型列表口径
...
- System One 校验拒绝重复键与大小写/Unicode 折叠变体键(请求顶层、
questions、问题对象):encoding/json 大小写不敏感且取最后一个重复键,
而原始 body 原样转发,此前 {"model":"x","MODEL":"jev-latest"} 可绕过
jev-latest 限制、模型白名单与流式限制。
- Prompt 审计与旧审核同时收集对象键名、问题 ID 与未知扩展字段(不含规范
字段名与已校验的 type),此前把内容放进键名即可完全绕过审计。
- 上游成功响应的 usage/model 宽松解码(浮点、数字字符串),避免上游已
计费而网关整体 502 不记账;解码失败记录 response_error ops 事件。
- 上游 413 与 400/422 同视为请求错误:透传状态码、不切换、不改账号状态。
- TypeSafe base_url 末尾的 /v1 自动剥离,避免拼出 /v1/v1/systemone;
/v1/systemone 改挂文本请求体上限。
- Composite 静态兜底模型列表、管理端候选列表恢复为不含 jev-latest;
Codex 清单永不列出 TypeSafe 模型;TypeSafe 分组候选默认 jev-latest。
- 创建账号从 Grok 切到 TypeSafe 时重置为白名单模式;错误透传平台列表补 typesafe。
2026-10-02 13:51:58 +08:00
shaw
2d8a386811
fix(typesafe): 补齐平台迁移、审计覆盖、端点隔离与错误策略
...
- 新增 241 迁移:user_platform_quotas / composite_model_routes 的 CHECK 约束
加入 typesafe。此前设置 typesafe 默认配额会让注册时的多行配额快照整体
违约(fail-open 后新用户所有平台配额丢失),单用户配额与 Composite 路由保存 500。
- Prompt 审计新增 typesafe_systemone 协议提取(state + 各问题 instructions/
criteria/选项标签,键排序保证哈希稳定);此前提取为空,阻断与异步审计均被放行。
旧内容审核同样覆盖问题文本,且不再丢弃含 <system-reminder> 的 System One 文本。
- TypeSafe 分组及路由到 TypeSafe 的 Composite 请求访问 Messages / count_tokens /
Chat Completions / Responses 时返回 404,避免以 x-api-key 打到错误上游路径并
污染账号状态;TypeSafe 账号 base_url 为空时不再回退 api.anthropic.com。
- SystemOne 补在途余额预留、利润控制准入终检、wrapReleaseOnDone,失败切换改用
共享 FailoverState(同账号重试 / 池模式 / 临时封禁)。
- 上游错误沿用共享账号错误策略:402/403、自定义错误码、临时不可调度规则生效,
记录 ops 上游错误;400/422 仍不切换且永不改变账号状态。
- 账号测试改走原生 System One 探测,可用模型只返回 jev-latest;
响应超限显式报错,响应 Content-Type 仅透传 JSON 类型。
2026-10-02 13:08:40 +08:00
aofee
7225538358
merge: sync Jev support with latest upstream main
2026-10-02 09:37:30 +08:00
Wesley Liddick
0dd71286f2
Merge pull request #7060 from heathermhuang/fix/composite-image-models-6076
...
fix(images): allow compatible Gemini models on API-key upstreams
2026-09-23 10:07:02 +08:00
aofee
d1ba57977d
feat: add native TypeSafe Jev System One support
2026-09-20 20:20:16 +08:00
Cai
aba34524f1
feat: support native Seedance Ark video task API
2026-09-17 04:14:14 +09:00
alfadb
a939553c87
fix(deepseek): 模型名校验不再默认兜底,未配置映射时按官方名单校验
...
- 未配置 model_mapping 的 DeepSeek 账号不再放行任意模型名,改为官方名单精确匹配
(deepseek-flash / deepseek-v4-pro / deepseek-v4-flash /
deepseek-v4-flash-vision-exp / deepseek-v4-pro-0813)
- 校验前先归一化:剥离 Claude Code 客户端上下文后缀 [1m](含重复形式)并统一小写,
使官方 Claude Code 接入写法 deepseek-flash[1m] 继续可用
- 未知模型名在调度阶段即拒绝,返回 404 model_not_found,避免透传上游后触发
per-(账号,模型) 冷却、并避免上游把不认识的模型名静默兜底成 deepseek-flash
- 出站前剥离泄漏的 [1m] 后缀,仅作用于 DeepSeek 平台
- 配置了 model_mapping 的账号语义不变(映射优先)
2026-09-15 10:42:29 +08:00
Heatherm Huang
9fedf899e2
fix(images): route compatible Gemini image models through API keys
2026-09-12 14:34:31 +08:00
Wesley Liddick
cdb5cfaf6c
Merge pull request #6747 from DuskLin/feat/opencode-go-platform
...
feat(opencode): 增加 OpenCode 平台支持(Zen / GO)
2026-09-11 16:42:05 +08:00
刘佳林
242907854d
feat(opencode): add OpenCode platform with Zen and GO account types
...
Keep the internal platform ID opencode_go. Product surface is OpenCode
with account_mode zen|go, model-aware routing across Chat Completions,
Responses, and Anthropic Messages, and X-OpenCode-Session derived from
prompt_cache_key / metadata.user_id so prompt cache can hit.
Unmatched models fall back to /v1/chat/completions. Related to #6742 .
2026-09-11 10:05:24 +08:00
lcy
29a36a10be
Merge upstream/main into feat/antigravity-gemini-3.8-flash
...
Resolve comment-wording conflict in normalizeGeminiThinkingTierAlias by
keeping upstream's phrasing. Function body and behavior are unchanged.
2026-09-09 01:49:32 +08:00
Wesley Liddick
dbe92a1c24
Merge pull request #6758 from DuskLin/feat/minimax-platform
...
feat(minimax): 增加 MiniMax 平台支持
2026-09-08 18:50:06 +08:00
刘佳林
3495635a52
fix(minimax): 补齐阈值停调与额度监控接线
...
调度阈值评估和渠道监控 quota 取数补上 MiniMax 分支;GetCodingPlanProvider 改为只认官方域名,避免把中转 Key 发到厂商额度端点。composite /v1/models 与 Codex 目录纳入 MiniMax;迁移改名为 237;allowlist 去掉未使用的 www.* / api.minimax.cn,abab 前缀收窄到 5/6/7。
2026-09-08 17:41:29 +08:00
刘佳林
19382f275e
feat(minimax): 增加 MiniMax 平台支持
...
把 MiniMax 做成与 Kimi / 智谱 / DeepSeek 同级的国产供应商平台:账号创建/编辑、分组、Composite 路由、原生 Token Plan / Coding Plan 额度,以及 OpenAI 兼容模型列表。
额度走 GET api.minimaxi.com|io /v1/api/openplatform/coding_plan/remains(Bearer)。只解析 model_name=general 的 remaining percent;周窗口仅在 current_weekly_status=1 时计入。
Related to #6742
2026-09-07 18:22:56 +08:00
doublepi123
8ed57b000c
feat(antigravity): support Gemini 3.7 Flash models
...
Google released Gemini 3.7 Flash on 2026-08-13. Register it alongside 3.8
using the same shape as the existing 3.6 entries: bare id plus the
Antigravity -high/-low/-medium/-tiered thinking tiers, the model catalog,
the custom-mapping passthroughs, fallback pricing and the tier alias
normalizer.
Pricing matches 3.8 at $0.75 input / $3.75 output / $0.075 cached input
per MTok. Both are promotional through 2026-12-31 and double on
2027-01-01; the constants note this.
Also corrects the 3.8 catalog timestamps to the documented GA dates.
2026-09-04 16:04:47 +08:00
doublepi123
27bcec7645
feat(antigravity): support Gemini 3.8 Flash models
...
Google released Gemini 3.8 Flash on 2026-09-02. Register the model and its
Antigravity thinking tiers the same way Gemini 3.6 Flash is registered:
- DefaultAntigravityModelMapping: bare id plus -high/-low/-medium/-tiered
- geminiModels catalog exposed through /antigravity/v1/models
- ensureAntigravityDefaultPassthroughs so accounts with a custom
model_mapping still resolve the new ids
- fallback pricing and the thinking-tier alias normalizer, so the tiers
share the base model price card instead of failing pricing lookup
Fallback rates are Google's published prices: $0.75 input / $3.75 output /
$0.075 cached input per MTok. These are promotional through 2026-12-31 and
double on 2027-01-01; the constant carries a note to that effect.
Refs #6523
2026-09-04 16:04:47 +08:00
aofee
a774230661
fix(grok): keep inconclusive billing accounts eligible
2026-09-02 11:09:21 +08:00
刘佳林
e377c4358c
feat(kimi): forward native OpenAI Responses API
...
Moonshot pay-as-you-go and Kimi For Coding both expose native
/v1/responses. Stop converting Kimi Responses traffic to Chat
Completions, and treat Kimi like DeepSeek for protocol selection while
keeping /v1/responses URL construction.
2026-09-01 16:50:04 +08:00
Wesley Liddick
844b118785
Merge pull request #5938 from Hakunm/fix/google-one-model-catalog
...
fix(gemini): 限制 Google One OAuth 模型目录 / constrain Google One model catalog
2026-08-22 13:34:05 +08:00
zcxads666
40c26f343a
fix(openai): 空 openai_capabilities 不再排除 OAuth 账号的文本调度(#5530)
2026-08-21 21:30:40 +08:00
Hakunm
f98a056f75
fix(gemini): constrain Google One model catalog
2026-08-21 02:33:00 +08:00
IanShaw
48615d5d1f
Merge remote-tracking branch 'upstream/main' into fix/openai-responses-compatibility
...
# Conflicts:
# backend/internal/handler/ops_error_logger.go
2026-08-20 00:31:12 -07:00
IanShaw
acce29af27
补齐 OpenAI 与 Grok 协议兼容处理
2026-08-19 23:13:29 -07:00