fix: 修正 chat-only API-key 账号上游端点被误记为 /v1/responses#3335
Merged
Wei-Shaw merged 1 commit intoJun 21, 2026
Conversation
… API-key accounts DeriveUpstreamEndpoint maps every OpenAI-platform request to /v1/responses, but API-key accounts whose upstream only speaks Chat Completions (!ShouldUseResponsesAPI) are forwarded directly to /v1/chat/completions. The messages, responses and cyber-policy recording sites derived the endpoint via the bare GetUpstreamEndpoint, so usage/ops records mislabeled those requests as /v1/responses. Generalize the existing resolveRawCCUpstreamEndpoint into resolveOpenAIUpstreamEndpoint and use it at every OpenAI recording site, matching the already-correct chat-completions client path.
Contributor
|
All contributors have signed the CLA. ✅ |
27e7793 to
bab8a9a
Compare
Contributor
Author
|
I have read the CLA Document and I hereby sign the CLA |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
问题
DeriveUpstreamEndpoint对所有 OpenAI 平台请求一律推导为/v1/responses,但 API-key 账号若上游只支持 Chat Completions(!ShouldUseResponsesAPI),实际是直接转发到/v1/chat/completions。messages / responses / cyber_policy 三类记录点都用裸的GetUpstreamEndpoint推导端点,导致这些请求在用量/ops 记录里被误标成/v1/responses。修复
把已有的
resolveRawCCUpstreamEndpoint(原本只用于 chat completions 客户端路径)泛化为resolveOpenAIUpstreamEndpoint,并在所有 OpenAI 记录点改用它——与早已修正的 chat completions 客户端路径保持一致。GetUpstreamEndpoint作为非 OpenAI 平台及该 resolver 的回退保留不变。影响
修复前:


修复后:
测试
go build ./internal/handler/ ./internal/service/通过;go test ./internal/handler/全量通过。