---
title: "Gemini API and cost"
url: https://phatdev.net/en/docs/aiusage/gemini-chi-phi
lang: en
updated: 2026-10-23
alternate:
  vi: https://phatdev.net/docs/aiusage/gemini-chi-phi
markdown: https://phatdev.net/en/docs/aiusage/gemini-chi-phi.md
---

# Gemini API and cost

Part of the doc set: [AIUsage](https://phatdev.net/en/docs/aiusage.md)

> Credit balance, cost from four data layers, an end-of-month projection and a 30-day spend calendar.

The Gemini API is the only source measured in money rather than quota percent. This card shows the credit balance, cost by day and by model, and how many days the balance will last.

<div style="margin:1.6em 0"><figure style="margin:0"><a href="https://phatdev.net/uploads/p/aiusage/codex-gemini-vi-light-3840.webp" target="_blank" rel="noopener" class="pd-th-light" style="display:block;border:0" aria-label="Codex 5-hour limit window by window, and the Gemini API: credit balance, cost by model, end-of-month projection (4K)"><img src="https://phatdev.net/uploads/p/aiusage/codex-gemini-vi-light-1920.webp" srcset="/uploads/p/aiusage/codex-gemini-vi-light-960.webp 960w, /uploads/p/aiusage/codex-gemini-vi-light-1920.webp 1920w, /uploads/p/aiusage/codex-gemini-vi-light-3840.webp 3840w" sizes="(max-width: 900px) 100vw, 760px" width="3840" height="2160" alt="Codex 5-hour limit window by window, and the Gemini API: credit balance, cost by model, end-of-month projection" loading="lazy" decoding="async" style="width:100%;height:auto;display:block;border:1px solid var(--line);border-radius:12px"></a><a href="https://phatdev.net/uploads/p/aiusage/codex-gemini-vi-dark-3840.webp" target="_blank" rel="noopener" class="pd-th-dark" style="display:block;border:0" aria-label="Codex 5-hour limit window by window, and the Gemini API: credit balance, cost by model, end-of-month projection (4K)"><img src="https://phatdev.net/uploads/p/aiusage/codex-gemini-vi-dark-1920.webp" srcset="/uploads/p/aiusage/codex-gemini-vi-dark-960.webp 960w, /uploads/p/aiusage/codex-gemini-vi-dark-1920.webp 1920w, /uploads/p/aiusage/codex-gemini-vi-dark-3840.webp 3840w" sizes="(max-width: 900px) 100vw, 760px" width="3840" height="2160" alt="Codex 5-hour limit window by window, and the Gemini API: credit balance, cost by model, end-of-month projection" loading="lazy" decoding="async" style="width:100%;height:auto;display:block;border:1px solid var(--line);border-radius:12px"></a><figcaption style="margin-top:8px;font-size:13px;line-height:1.5;color:var(--muted);text-align:center">Codex 5-hour limit window by window, and the Gemini API: credit balance, cost by model, end-of-month projection</figcaption></figure></div>

## Cost comes from four layers of data

AIUsage combines several sources to give the best figure at any moment:

1. **Cloud Monitoring:** token and request counts per model per day. Cost is estimated as tokens times Google's price list.
2. **A local price table:** per-model prices stored locally. A model with no price shows "no price yet" instead of being counted as zero.
3. **BigQuery billing export:** exact daily cost, cache discounts included, once Google has created the export table. Queried at most every 6 hours.
4. **The AI Studio Billing page:** credit balance, latest top-up, tier cap and Google's own month-to-date total, read through the helper.

BigQuery can lag by several days. Until it catches up, "today" and "7 days" use the estimate and the label reads "exact up to ...". Top-up invoices, which belong to no project, are not added to monthly spend.

## What the card shows

| Item | Meaning |
|---|---|
| Credit balance | The current balance and the latest top-up |
| Today, 7 days, month | Cost for each period; the monthly figure says "exact" when it comes from BigQuery |
| AI Studio reports this month | Google's own figure for comparison; a token-based estimate typically runs about 10% high because it ignores cache discounts |
| Progress to the next tier | Cumulative spend against the threshold for the next tier |
| By model | Share of spend, request count and tokens in and out for each model |
| Forecast | End-of-month spend at the current pace, days the balance will last, average daily spend |

## 30-day spend calendar

A weekly grid of cells: each cell is a day, darker for higher spend, and the outlined cell is today. See [Widget and dashboard window](https://phatdev.net/en/docs/aiusage/widget-cua-so).
