fix(costs): count input images for gemini-3.1-flash-image-preview - #1790
Conversation
The input image counting for cost calculation was only checking for gemini-3-pro-image-preview. This adds gemini-3.1-flash-image-preview to the condition so image costs are correctly tracked for that model too. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (2)
WalkthroughThe PR extends the input image counting logic to include an additional Gemini model variant ("gemini-3.1-flash-image-preview") alongside the existing "gemini-3-pro-image-preview". The documentation comment is updated to reflect this broader model support. Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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 |
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where input images were not counted (and therefore not billed) when using the gemini-3.1-flash-image-preview model. Previously, the input-image-counting guard in chat.ts only matched gemini-3-pro-image-preview. The fix extends that condition to include the new model, and updates the function's doc comment accordingly.
Changes:
- Extended the
requestedModelcheck inchat.tsto also triggercountInputImagesforgemini-3.1-flash-image-preview. - Updated the JSDoc comment in
count-input-images.tsto list both supported models.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
apps/gateway/src/chat/chat.ts |
Adds gemini-3.1-flash-image-preview to the input image counting condition |
apps/gateway/src/chat/tools/count-input-images.ts |
Updates doc comment to reflect both image models that use this function |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
| requestedModel === "gemini-3-pro-image-preview" || | ||
| requestedModel === "gemini-3.1-flash-image-preview" |
There was a problem hiding this comment.
The existing costs.spec.ts tests verify input image counting and cost calculation for gemini-3-pro-image-preview, but there is no equivalent test covering gemini-3.1-flash-image-preview with a non-zero inputImageCount. Given that imageInputPrice is looked up per provider configuration, adding a parallel test case that passes inputImageCount > 0 for gemini-3.1-flash-image-preview would confirm the fix works end-to-end and that the model's provider entry has imageInputPrice configured.
Summary
gemini-3.1-flash-image-previewto the input image counting condition inchat.tsso image costs are correctly calculated for that modelcount-input-images.tsto reflect both supported image modelsTest plan
gemini-3.1-flash-image-previewgemini-3-pro-image-previewbehavior is unchanged🤖 Generated with Claude Code
Summary by CodeRabbit
New Features
Documentation