fix(relay): reject image models on chat completions - #6478
Conversation
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (3)
WalkthroughImage-generation model patterns now include current image model variants. Chat-completions validation rejects image-generation models with guidance to use the images endpoint, while text-model requests continue to succeed. ChangesImage model endpoint validation
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
7708a1e to
1186b91
Compare
51fdfc5 to
2b6f1df
Compare
📝 变更描述 / Description
修复图片生成模型可通过
/v1/chat/completions被当作文本补全转发和计费的问题。/v1/images/generations。gpt-image-*识别改为前缀匹配,覆盖gpt-image-2、模型快照和后续版本;同时覆盖chatgpt-image-latest与 DALL·E。校验发生在 token 估算、预扣费和上游转发之前,避免错误端点请求造成额度消耗。
🚀 变更类型 / Type of change
🔗 关联任务 / Related Issue
Related to #6308.
✅ 提交前检查项 / Checklist
go test ./relay/helper -run 'TestChatCompletionsRejectsImageGenerationModels|TestChatCompletionsAcceptsTextModel' -count=1通过;其余后端包测试也已通过。📸 运行证明 / Proof of Work
修复后,以下请求会在 Relay 入口返回 400,而不会选择渠道或扣费:
POST /v1/chat/completions{ "model": "gpt-image-2", "stream": true, "messages": [{"role":"user","content":"Generate an image"}] }错误信息:
model "gpt-image-2" is not supported on /v1/chat/completions; use /v1/images/generations instead📸 运行证明 / Proof of Work
使用
gpt-image-2请求/v1/chat/completions,现在在 Relay 入口返回 400,未进入上游转发或计费流程。
本地回归测试: