Skip to content

feat: Anthropic 模型路由支持 Codex OAuth 账号#1672

Open
JialinLiu-codedance wants to merge 1 commit intoWei-Shaw:mainfrom
JialinLiu-codedance:codex/anthropic-model-routing-codex
Open

feat: Anthropic 模型路由支持 Codex OAuth 账号#1672
JialinLiu-codedance wants to merge 1 commit intoWei-Shaw:mainfrom
JialinLiu-codedance:codex/anthropic-model-routing-codex

Conversation

@JialinLiu-codedance
Copy link
Copy Markdown

@JialinLiu-codedance JialinLiu-codedance commented Apr 15, 2026

修改范围

本次扩展 Anthropic 分组的显式模型路由能力,让 model_routing 可以选择 Codex 账号(限定为 OpenAI OAuth 账号)作为路由目标。设计上保持现有 REST 接口、分组配置结构和账号表结构不变,并且不把 OpenAI OAuth 账号加入 Anthropic 分组的默认调度池,只有显式路由规则命中时才允许进入兼容转发路径。

修改内容

  • 前端分组管理的 Anthropic 模型路由账号搜索同时合并 anthropic 账号与 openai/oauth 账号候选,并在候选与已选标签中标识 AnthropicCodex / OpenAI OAuth
  • 后端调度在 Anthropic 分组的显式 model_routing 命中分支中解析并校验 OpenAI OAuth 账号,继续保留可调度、模型支持、排除列表、分组绑定等运行时约束。
  • 保持普通 Layer 2/Layer 3 选号逻辑不扩容到 OpenAI,未命中路由规则时 OpenAI OAuth 账号不会参与 Anthropic 默认候选池。
  • GatewayHandler.Messages 在选中 OpenAI OAuth 账号时复用现有 OpenAI Responses 兼容链路,将 Anthropic Messages 请求转发为 OpenAI Responses,再转换回 Anthropic 兼容响应。
  • 补充前端候选搜索测试、后端转发路径判断测试,以及 Anthropic 显式路由到 OpenAI OAuth 的调度测试。

如何测试

  • pnpm test:run src/views/admin/__tests__/groupsModelRoutingAccounts.spec.ts
  • pnpm typecheck
  • go test ./internal/handler -run TestMessagesForwardRouteKind -count=1
  • go test -tags unit ./internal/service -run '^TestGatewayService_SelectAccountWithLoadAwareness$' -count=1 -v

Anthropic model routing is explicitly configured, so Codex/OpenAI OAuth accounts can be treated as routed targets without expanding the default Anthropic scheduling pool. The gateway dispatch path reuses the existing OpenAI Responses compatibility forwarder when an Anthropic group selects an OpenAI OAuth account.

Constraint: Codex account support is limited to platform=openai and type=oauth
Constraint: Public API shapes and group/account schemas must remain unchanged
Rejected: Add OpenAI OAuth accounts to the normal Anthropic candidate pool | would change default scheduling behavior
Rejected: Add new routing fields | model_routing already stores explicit account IDs
Confidence: high
Scope-risk: moderate
Directive: Do not allow OpenAI accounts into Anthropic default scheduling; only explicit model_routing hits may use this path
Tested: pnpm test:run src/views/admin/__tests__/groupsModelRoutingAccounts.spec.ts
Tested: pnpm typecheck
Tested: go test ./internal/handler -run TestMessagesForwardRouteKind -count=1
Tested: go test -tags unit ./internal/service -run '^TestGatewayService_SelectAccountWithLoadAwareness$' -count=1 -v
Not-tested: Full backend test suite
@JialinLiu-codedance JialinLiu-codedance changed the title Support Codex OAuth accounts in Anthropic model routing feat: Anthropic 模型路由支持 Codex OAuth 账号 Apr 15, 2026
@Wei-Shaw Wei-Shaw force-pushed the main branch 4 times, most recently from 1e0d466 to 4d0483f Compare April 22, 2026 10:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant