Skip to content

新增账号支持使用 Chat Completions 协议上游#2255

Open
DASungta wants to merge 3 commits intoWei-Shaw:mainfrom
DASungta:feat/apikey-chat-completions-bridge
Open

新增账号支持使用 Chat Completions 协议上游#2255
DASungta wants to merge 3 commits intoWei-Shaw:mainfrom
DASungta:feat/apikey-chat-completions-bridge

Conversation

@DASungta
Copy link
Copy Markdown

@DASungta DASungta commented May 7, 2026

Summary

  • 新增 apikey-chat-completions 账号类型,将 Anthropic Messages / OpenAI Responses API 流量桥接到只支持 Chat Completions 协议的上游(如 b.ai 等)
  • 新增 strip_reasoning_effort_on_cc 账号字段,适配拒绝 reasoning_effort 参数的 Chat Completions 上游
  • 新增双向协议转换器 Responses↔ChatCompletionsapicompat 包),附完整单元测试链式覆盖
  • 前端创建/编辑账号弹窗同步新增相关字段开关

Changes

Backend

模块 变更内容
ent/schema/account type 字段扩至 40 字符;新增 strip_reasoning_effort_on_cc bool 字段
migrations/020 宽化 accounts.type
migrations/021 新增 strip_reasoning_effort_on_cc
internal/pkg/apicompat 新增 responses_to_chatcompletions_request.go + chatcompletions_to_responses_response.go 及对应测试
internal/service 新增 gateway_claude_chat_completions_raw.gogateway_forward_anthropic_as_cc.goopenai_gateway_responses_to_cc.go 及对应测试
internal/handler/openai_gateway_handler 新增 Responses→CC 路由分支
internal/handler/admin CRUD API 透传新字段

Frontend

  • CreateAccountModal.vue / EditAccountModal.vue:新增 strip_reasoning_effort_on_cc 开关
  • i18n/locales/en.ts / zh.ts:补充新字段国际化文案

Test plan

  • go test -tags=unit ./... 全部通过(TestResolvePageImagePath 为 macOS /private/var 预存失败,与本 PR 无关)
  • 新增 apicompat 链式转换测试:Responses→CC 请求转换、CC→Responses 响应转换
  • 新增 handler-level E2E 测试:anthropic_messages_apikey_ccopenai_chat_completions_apikey_ccopenai_responses_apikey_cc
  • go build ./... 编译通过
  • Ent 生成代码已提交(ent/ 目录)

🤖 Generated with Claude Code

DASungta and others added 2 commits May 7, 2026 18:09
…pletions bridge

Introduce a new account type `apikey-chat-completions` that allows
forwarding Anthropic/Responses API traffic to upstreams that only speak
the OpenAI Chat Completions protocol. Includes:

- ent schema: widen `type` column to 40 chars; add `strip_reasoning_effort_on_cc` field
- migrations 020/021 for the schema changes
- apicompat: bidirectional Responses↔ChatCompletions converters
  (`responses_to_chatcompletions_request`, `chatcompletions_to_responses_response`)
- fix: preserve tool messages with call_id in normalizeChatMessagesForToolCallPairs
- service: gateway routing for the new account type (Claude raw + Anthropic-as-CC + Responses-to-CC)
- handler/admin: surface strip_reasoning_effort_on_cc in account CRUD API
- frontend: add strip_reasoning_effort_on_cc toggle to CreateAccountModal & EditAccountModal

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

All contributors have signed the CLA. ✅
Posted by the CLA Assistant Lite bot.

@DASungta
Copy link
Copy Markdown
Author

DASungta commented May 7, 2026

I have read the CLA Document and I hereby sign the CLA

github-actions Bot added a commit that referenced this pull request May 7, 2026
@DASungta
Copy link
Copy Markdown
Author

DASungta commented May 7, 2026

1 4 3 2

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