新增账号支持使用 Chat Completions 协议上游#2255
Open
DASungta wants to merge 6 commits into
Open
Conversation
…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>
Contributor
|
All contributors have signed the CLA. ✅ |
Author
|
I have read the CLA Document and I hereby sign the CLA |
Author
|
请求合并,很需要这个功能 |
|
这个功能很有用!支持合并 |
gclm
added a commit
to gclm/sub2api
that referenced
this pull request
May 18, 2026
…protocol bridging 新增 apikey-chat-completions 账号类型,将 Anthropic Messages / OpenAI Responses 流量桥接到只支持 Chat Completions 协议的上游;新增 Responses↔ChatCompletions 双向转换器及前端字段支持。
|
麻烦大佬更新一下 |
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Allow apikey-chat-completions accounts to select Authorization, api-key, or x-api-key authentication headers, and preserve exact Chat Completions test URLs. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Resolve PR Wei-Shaw#2255 conflicts with upstream's gateway refactor: - openai_gateway_handler.go: keep WS chat-completions branch (ProxyResponsesWebSocketAsChatCompletions) and adopt upstream's pre-hooks requestPayloadHash computation. - Adapt to parsed.Body now being *RequestBodyRef: use .Bytes() in ForwardAnthropicAsChatCompletions and NewRequestBodyRef() in apikey-chat-completions tests. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Author
|
已经解决冲突并且更新到最新了。 作者估计没有合并的想法,可以直接用我的docker镜像进行部署:
版本号会和源项目保持一致。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.





Summary
apikey-chat-completions账号类型,将 Anthropic Messages / OpenAI Responses API 流量桥接到只支持 Chat Completions 协议的上游(如 b.ai 等)strip_reasoning_effort_on_cc账号字段,适配拒绝reasoning_effort参数的 Chat Completions 上游Responses↔ChatCompletions(apicompat包),附完整单元测试链式覆盖Changes
Backend
ent/schema/accounttype字段扩至 40 字符;新增strip_reasoning_effort_on_ccbool 字段migrations/020accounts.type列migrations/021strip_reasoning_effort_on_cc列internal/pkg/apicompatresponses_to_chatcompletions_request.go+chatcompletions_to_responses_response.go及对应测试internal/servicegateway_claude_chat_completions_raw.go、gateway_forward_anthropic_as_cc.go、openai_gateway_responses_to_cc.go及对应测试internal/handler/openai_gateway_handlerinternal/handler/adminFrontend
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 响应转换anthropic_messages_apikey_cc、openai_chat_completions_apikey_cc、openai_responses_apikey_ccgo build ./...编译通过ent/目录)🤖 Generated with Claude Code