Skip to content

fix(channel-test): auto-detect image generation models#6122

Open
lichengzhe wants to merge 1 commit into
QuantumNous:mainfrom
lichengzhe:fix/channel-test-image-auto-detect
Open

fix(channel-test): auto-detect image generation models#6122
lichengzhe wants to merge 1 commit into
QuantumNous:mainfrom
lichengzhe:fix/channel-test-image-auto-detect

Conversation

@lichengzhe

@lichengzhe lichengzhe commented Jul 11, 2026

Copy link
Copy Markdown

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

渠道测试使用「自动检测」时,gpt-image-2 会被当成聊天模型,请求发到 /v1/chat/completions,导致上游报错(#6121)。

本 PR 做了这些调整:

  • gpt-image-1 的精确匹配改为匹配整个 gpt-image-* 系列,同时支持 openai/gpt-image-3 这类带命名空间的名称。
  • 渠道测试统一使用模型分类器。识别为图像模型后,会同时使用 /v1/images/generationsdto.ImageRequest,避免请求路径与请求体不一致。
  • 手动指定的端点仍然优先。
  • 保留火山引擎 Seedream 的自动识别,并改为不区分大小写,Seedream-4.0 也能正常识别。

自动检测会对所有渠道类型生效。dall-efluximagen 等已知图像模型也会自动走图像端点。如果个别上游通过聊天接口代理图像模型,仍可手动指定端点覆盖。

定价页复用同一个分类器,因此 gpt-image-2 的端点类型也会显示为 [image-generation, openai]

本 PR 在 AI 辅助下完成,实现、测试、影响范围与本描述均经本人复核。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

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

📸 运行证明 / Proof of Work

以下测试已通过:

go test ./common ./controller -count=1
ok github.com/QuantumNous/new-api/common
ok github.com/QuantumNous/new-api/controller

回归测试覆盖:

  • gpt-image-1gpt-image-2、带命名空间及未来的 gpt-image-* 名称
  • 手动指定端点的优先级
  • 图像请求路径与 dto.ImageRequest 保持一致
  • 火山引擎 Seedream,包括 Seedream-4.0 的大小写场景
  • 普通聊天模型行为不变
  • 定价元数据正确返回 [image-generation, openai]

其余 Go 包的测试也已通过。只有仓库根目录的 setup 因本地缺少生成产物 web/classic/dist 无法运行,与本次改动无关。

Summary by CodeRabbit

  • New Features

    • Added broader support for GPT image model variants, including newer and differently formatted model names.
    • Image-generation requests are now automatically detected and routed to the appropriate image endpoint.
    • Image model testing now uses the expected image request format and default settings.
  • Bug Fixes

    • Improved endpoint selection for image-generation models across supported providers, while preserving automatic handling for chat models.

@coderabbitai

coderabbitai Bot commented Jul 11, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

GPT image model detection now covers the gpt-image- family. Endpoint preference and channel-test auto-detection route these models to image-generation requests while preserving explicit endpoint selection.

Changes

Image endpoint detection

Layer / File(s) Summary
GPT image model classification and endpoint preference
common/model.go, common/model_test.go
GPT image model matching uses the gpt-image- family prefix, with tests covering model recognition and image-generation endpoint ordering.
Channel-test image request routing
controller/channel-test.go, controller/channel_test_internal_test.go
Automatic channel-test detection maps image models to the image-generation endpoint, removes the Seedream-specific path override, and validates image probe construction and explicit endpoint precedence.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

Poem

A rabbit hops past chat’s old door,
“GPT images belong by /images/generations floor!”
Prefixes bloom, probes shape up,
Explicit choices stay in the cup.
Carrots for tests—hip-hop hooray!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes address issue #6121 by classifying gpt-image-* as image-generation, routing auto-detect to images, and preserving explicit endpoint precedence.
Out of Scope Changes check ✅ Passed The modified code and tests stay focused on image-generation auto-detection and related pricing metadata, with no unrelated changes evident.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and accurately summarizes the main change to auto-detect image generation models.
✨ 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.

bug: channel test auto-detection sends gpt-image-2 to chat completions

1 participant