Skip to content

fix(go): preserve usage on cross-protocol streams - #298

Merged
LIghtJUNction merged 7 commits into
mainfrom
fix/go-cross-protocol-stream-usage
Sep 15, 2026
Merged

LIghtJUNction merged 7 commits into
mainfrom
fix/go-cross-protocol-stream-usage

Conversation

@LIghtJUNction

Copy link
Copy Markdown
Member

LMM API Pull Request

变更说明 / Summary

Backport the production-relevant part of QuantumNous/new-api#7389. Cross-protocol requests converted into OpenAI Chat Completions now request stream_options.include_usage=true when the selected upstream supports stream options and the request is streaming.

The policy is enforced at the Go host conversion facade so it consistently covers direct format conversion and explicit converter-ID routes used by advanced-custom channels. Non-stream requests and upstreams without stream-options support remain unchanged.

与上游的关系 / Upstream relationship

  • LMM API 独有变更 / LMM API-specific change
  • 上游尚未合并的修复或功能 / Change not yet merged upstream
  • 同步或移植上游变更 / Upstream sync or backport
  • 不适用(文档、CI、仓库维护等)/ Not applicable

上游参考 / Upstream reference: QuantumNous/new-api#7389, commit 610334dbd760f1c5199a09ae5f860f11451f4c56 (2026-09-15).

关联 Issue / Related issue

Closes #297

变更类型 / Type of change

  • Bug 修复 / Bug fix
  • 新功能 / Feature
  • 重构或性能优化 / Refactor or performance
  • 前端或交互 / Frontend or UX
  • 部署、CI 或构建 / Deployment, CI, or build
  • 文档或仓库维护 / Documentation or maintenance

验证 / Verification

regression coverage:
- direct Gemini -> OpenAI Chat stream requests usage
- advanced-custom Claude -> OpenAI Chat stream requests usage
- advanced-custom Gemini -> OpenAI Chat stream requests usage
- advanced-custom Responses -> OpenAI Chat stream requests usage
- non-stream leaves stream options unset
- unsupported upstream leaves stream options unset

GitHub PR CI: pending; merge is blocked until required checks pass.

截图或日志 / Screenshots or logs

N/A. Backend request-conversion/billing correctness change only.

提交检查 / Checklist

  • 我已搜索本仓库的 Issues 和 PRs,确认没有重复工作。
  • 此 PR 只包含与当前目标相关的改动,未混入格式化或其他无关变更。
  • 我已说明该变更对当前产品流程或兼容行为的影响,并保留必要的来源、版权和许可证信息。
  • 我已检查兼容性;如有破坏性变化,已在说明中明确列出迁移方式。
  • 我已补充或更新相关测试,并在上方记录实际验证结果;如未测试,已说明原因。
  • 我已更新受影响的文档、示例配置和多语言文案(如适用)。
  • 代码、日志、截图和提交记录中不包含 API Key、Cookie、Token、密码、DSN 或其他敏感信息。

Copilot AI lite review requested due to automatic review settings September 15, 2026 06:02
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

2 similar comments
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, add credits to your account and enable them for code reviews in your settings.

@LIghtJUNction
LIghtJUNction merged commit 5d0e091 into main Sep 15, 2026
17 checks passed
@LIghtJUNction
LIghtJUNction deleted the fix/go-cross-protocol-stream-usage branch September 21, 2026 15:46
LIghtJUNction added a commit that referenced this pull request Sep 21, 2026
Backport the production-relevant cross-protocol stream usage fix from QuantumNous/new-api#7389.

Request upstream usage for supported streaming Gemini -> OpenAI Chat conversions and advanced-custom Claude/Gemini/Responses -> OpenAI Chat converters, while preserving non-stream, unsupported-upstream, and internal Claude staging behavior.

Closes #297.
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.

[Go][Billing] Preserve stream usage on cross-protocol OpenAI chat conversions

2 participants