Skip to content

fix(costs): count input images for gemini-3.1-flash-image-preview - #1790

Merged
smakosh merged 1 commit into
mainfrom
add-gemini-3-1-image-model
Mar 4, 2026
Merged

smakosh merged 1 commit into
mainfrom
add-gemini-3-1-image-model

Conversation

@steebchen

@steebchen steebchen commented Mar 4, 2026

Copy link
Copy Markdown
Member

Summary

  • Added gemini-3.1-flash-image-preview to the input image counting condition in chat.ts so image costs are correctly calculated for that model
  • Updated doc comment in count-input-images.ts to reflect both supported image models

Test plan

  • Verify cost calculation includes input images when using gemini-3.1-flash-image-preview
  • Verify existing gemini-3-pro-image-preview behavior is unchanged

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Extended image counting functionality to support an additional Gemini model variant in cost calculations.
  • Documentation

    • Updated documentation to reflect expanded model support in the image counting feature.

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>
Copilot AI review requested due to automatic review settings March 4, 2026 17:44
@coderabbitai

coderabbitai Bot commented Mar 4, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 96b46a49-537e-4373-b4cf-cfde5e94fd02

📥 Commits

Reviewing files that changed from the base of the PR and between 90d7378 and ef62412.

📒 Files selected for processing (2)
  • apps/gateway/src/chat/chat.ts
  • apps/gateway/src/chat/tools/count-input-images.ts

Walkthrough

The 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

Cohort / File(s) Summary
Image Counting for Gemini Models
apps/gateway/src/chat/chat.ts, apps/gateway/src/chat/tools/count-input-images.ts
Extended input image counting to include "gemini-3.1-flash-image-preview" model variant; updated related documentation comment.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Possibly related PRs

Suggested reviewers

  • smakosh
🚥 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 clearly and accurately describes the main change: adding support for counting input images for the gemini-3.1-flash-image-preview model variant in the costs logic.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch add-gemini-3-1-image-model

Tip

Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs).
Share your feedback on Discord.


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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 requestedModel check in chat.ts to also trigger countInputImages for gemini-3.1-flash-image-preview.
  • Updated the JSDoc comment in count-input-images.ts to 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.

Comment on lines +437 to +438
requestedModel === "gemini-3-pro-image-preview" ||
requestedModel === "gemini-3.1-flash-image-preview"

Copilot AI Mar 4, 2026

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot uses AI. Check for mistakes.
@smakosh
smakosh added this pull request to the merge queue Mar 4, 2026
Merged via the queue into main with commit 506a041 Mar 4, 2026
17 of 18 checks passed
@smakosh
smakosh deleted the add-gemini-3-1-image-model branch March 4, 2026 18:24
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