Skip to content

[BUG] Gemini: Local cost calculation ignores tiered pricing and cache discounts #8017

@ikumi3

Description

@ikumi3

Problem (one or two sentences)

When using Gemini through Vertex AI, tiered pricing and cache discounts are not applied in the local cost calculation, causing displayed costs to always show the highest tier rates instead of the correct discounted rates.

Context (who is affected and when)

Who is affected:

  • All users using Gemini models through Vertex AI
  • Users monitoring costs through Roo-Code's local logs and UI
  • Users expecting accurate cost tracking and reporting

When this occurs:

  • When using Vertex AI provider with Gemini models
  • During local cost calculation in the calculateCost method
  • Affects cost display in ui_messages.json and local cost tracking
  • Note: Actual billing by Google Cloud/Vertex AI remains correct

Reproduction steps

  1. Configure Roo-Code to use Vertex AI with a Gemini model (gemini-2.5-pro)
  2. Set up Vertex AI credentials (project ID, region, authentication)
  3. Make an API call that generates significant token usage
  4. Check the cost displayed in ui_messages.json or local logs
  5. Compare with expected cost calculation using tiered pricing and cache discounts

Expected result

Displayed cost should reflect tiered pricing and cache discounts

Actual result

Displayed cost always shows high-tier pricing applied to all tokens

Variations tried (optional)

No response

App Version

v3.28.1

API Provider (optional)

Google Vertex AI

Model Used (optional)

gemini-2.5-pro

Roo Code Task Links (optional)

No response

Relevant logs or errors (optional)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue - Unassigned / ActionableClear and approved. Available for contributors to pick up.bugSomething isn't working

    Type

    No type

    Projects

    Status

    Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions