Skip to content

feat: support Tencent TokenHub API key via OpenAI-compatible protocol#6232

Open
feitianbubu wants to merge 2 commits into
QuantumNous:mainfrom
feitianbubu:pr/45f4da8a0
Open

feat: support Tencent TokenHub API key via OpenAI-compatible protocol#6232
feitianbubu wants to merge 2 commits into
QuantumNous:mainfrom
feitianbubu:pr/45f4da8a0

Conversation

@feitianbubu

@feitianbubu feitianbubu commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

📝 变更描述 / Description

腾讯云新的 TokenHub 平台发的是单段 sk 密钥,走 OpenAI 兼容协议,和旧混元三段式 AppId|SecretId|SecretKey(TC3 签名)不是一套东西。旧混元平台2026-06-22已开始下线, 2026-09-30 停服,新购只能用 TokenHub 的 api key。

改法: 因为新版兼容oai格式, 因此改法比较简单, key 含 | 走原来 TC3逻辑,api key 走 OpenAI 兼容的实现即可, 代码改动较小

迁服新闻: https://cloud.tencent.com/announce/detail/2310
新版平台: https://console.cloud.tencent.com/tokenhub/models

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix)
  • ✨ 新功能 (New feature)
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

新建渠道,优化提示:
image
新版渠道,自测通过:
image

由于旧版渠道已无法新建,因此无法自测, 通过断点验证了旧的的url 和 tc3段key和签名正常

@coderabbitai

coderabbitai Bot commented Jul 15, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Tencent channels now select native or OpenAI-compatible adaptors from the API key format, default compatible requests to the TokenHub endpoint, support streaming, and display updated key-format guidance.

Changes

Tencent adaptor dispatch

Layer / File(s) Summary
Tencent adaptor selection and wiring
relay/channel/tencent/dispatch.go, relay/relay_adaptor.go
Tencent initialization selects the native adaptor for legacy pipe-delimited keys and the OpenAI-compatible adaptor otherwise, with exported model/channel selectors and updated adaptor wiring.
Channel capability and key guidance
relay/common/relay_info.go, web/default/src/features/channels/constants.ts
Tencent is marked as stream-capable, and the channel prompt accepts TokenHub API keys or the legacy format.

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: calcium-ion

Poem

A rabbit hops where Tencent flows,
With keys in forms the channel knows.
Native paths and OpenAI,
Streamy requests now reach the sky.
TokenHub guidance helps them go.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly summarizes the main change: Tencent TokenHub API key support via the OpenAI-compatible protocol.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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