You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Go][Billing] Preserve stream usage on cross-protocol OpenAI chat conversions #297
Upstream QuantumNous/new-api merged #7389 on 2026-09-15 (610334dbd760f1c5199a09ae5f860f11451f4c56) after identifying that streaming requests converted from Gemini/Claude/Responses into OpenAI Chat Completions can lose upstream usage because the converted request does not ask for stream_options.include_usage.
Local evidence
Current Go main has the same gap:
apps/api-go/relay/channel/advancedcustom/adaptor.go converts Claude, Gemini, and Responses requests to OpenAI Chat but forwards the converted request without forcing StreamOptions.IncludeUsage for streaming requests.
apps/api-go/relay/channel/openai/adaptor.go already does this for Claude conversion, but Gemini conversion does not.
When the upstream supports stream options, the downstream protocol cannot carry the OpenAI stream_options request field itself. Missing usage can therefore degrade billing/usage correctness on cross-protocol streaming paths.
Required work
For cross-protocol conversions into OpenAI Chat, set stream_options.include_usage=true only when RelayInfo.SupportStreamOptions && RelayInfo.IsStream.
Preserve non-stream behavior and channels that do not support stream options.
Cover advanced-custom Claude/Gemini/Responses conversion plus the direct OpenAI-channel Gemini conversion with regression tests.
Do not alter request/response protocol semantics beyond requesting usage from the upstream.
Activity
fix(go): preserve usage on cross-protocol streams (#298)
fix(go): preserve usage on cross-protocol streams (#298)