Skip to content

feat: Force beta=true parameter for Anthropic channel - #2874

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
MUTED64:main
Feb 7, 2026
Merged

feat: Force beta=true parameter for Anthropic channel#2874
seefs001 merged 1 commit into
QuantumNous:mainfrom
MUTED64:main

Conversation

@MUTED64

@MUTED64 MUTED64 commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

WHY

部分 Claude 中转商对请求路径有策略差异,需要显式携带 ?beta=true 才能放行,目前 new-api 缺少按渠道强制 beta query 的配置能力,因此在渠道配置种提供可控开关,在管理后台可配置是否强制追加 ?beta=true。

WHAT

  1. 后端支持渠道配置中指定 beta=true
  • 在 ChannelOtherSettings 新增字段:claude_beta_query: boolean
  • Claude Relay 判定逻辑更新:请求携带 beta=true 或 渠道配置 claude_beta_query=true 时,启用 IsClaudeBetaQuery
  1. 前端管理页新增配置开关
  • 在渠道编辑页(Claude 渠道),“渠道额外设置”部分新增开关:
    • Claude 强制 beta=true
  • 语义上将该开关放在“渠道额外设置”区域,避免与“字段透传控制”混淆。

测试与验证

已完成以下验证,功能通过:

  1. 后端构建与测试
  • go test ./relay/common ./dto 通过
  • go build ./... 通过
  1. 前端构建
  • bun run build 通过(生成 web/dist)
  1. 功能验证
  • Claude 渠道开启 Claude 强制 beta=true 后,即使客户端不传 ?beta=true,请求也能按预期走 beta query 链路;
  • 保持向后兼容:客户端显式传 ?beta=true 仍生效;
  • 未开启开关的渠道行为不变。

Summary by CodeRabbit

  • New Features
    • Added a Claude beta query toggle to Claude channel configuration settings
    • New setting in the channel modal to enable forced beta mode for Claude API requests

@coderabbitai

coderabbitai Bot commented Feb 6, 2026

Copy link
Copy Markdown
Contributor

Walkthrough

This pull request adds a new Claude beta query forcing feature by introducing a ClaudeBetaQuery boolean field to channel settings, implementing a backend check that forces Claude requests to use beta when enabled, and adding frontend UI controls to toggle this setting for Claude channels.

Changes

Cohort / File(s) Summary
Data Transfer Object
dto/channel_settings.go
Added ClaudeBetaQuery boolean field to ChannelOtherSettings struct with JSON serialization support for the new setting.
Relay Logic
relay/common/relay_info.go
Modified Claude beta query detection to check both HTTP query parameters and a new isClaudeBetaForced() helper function that reads the ClaudeBetaQuery setting from context, centralizing the force-beta decision logic.
Frontend UI
web/src/components/table/channels/modals/EditChannelModal.jsx
Added UI switch in Channel Extra Settings for Claude channels to toggle the claude_beta_query setting, with data binding to parse and persist the setting through the channel configuration workflow.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 A whisker-twitching cheer for Claude's new mode,
Where beta queries flow down the code-hopping road,
A toggle, a check, a setting so fine,
The channels now shimmer with freshly-wired shine! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: Force beta=true parameter for Anthropic channel' clearly describes the main change: adding functionality to force a beta query parameter for Anthropic (Claude) channels, which is the core purpose of all three modified files.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

@seefs001
seefs001 merged commit 5f6f95c into QuantumNous:main Feb 7, 2026
1 check passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
feat: Force beta=true parameter for Anthropic channel
@ttimasdf

ttimasdf commented Mar 18, 2026

Copy link
Copy Markdown

IsClaudeBetaQuery 在渠道测试请求里不生效,请问这是预期行为吗?

edit: 感觉是bug,新增 issue #3305

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.

3 participants