Skip to content

Gemini API

  • Gemini API spend by model and SKU (input, output and cached tokens)

Method: Workload Identity Federation (BigQuery Billing Export)

The Gemini API (Google AI Studio) has no billing API. Its charges go through the Cloud Billing account linked to your Gemini API project, so Plutus reads them from that account’s Cloud Billing export to BigQuery.

Access uses the same keyless mechanism as the GCP source: Plutus proves its identity to a workload identity pool you control and receives a short-lived token for a service account in your project. No service account key is created or pasted, so organizations that block key creation work as is.

  1. In the Google Cloud console, go to Billing → Billing export → BigQuery export and enable Standard usage cost. Pick or create a dataset to export into. Skip this step if the export is already on. The export only contains usage from the day you enable it, with no backfill.
  2. Set up the workload identity pool, provider and service account by following the GCP connection steps (the Plutus Terraform module does all of it). If you already connected GCP, reuse its pool, provider and service account. The service account needs read access to the export dataset (bigquery.datasets.get, bigquery.tables.get, bigquery.tables.getData, bigquery.tables.list) and bigquery.jobs.create, which the module grants.
  3. In Plutus, enter:
    • GCP Project ID: the project that owns the BigQuery export dataset. It isn’t necessarily the project your Gemini API key belongs to.
    • Billing Account ID: the Cloud Billing account your Gemini API project is linked to, under Billing → Account management.
    • BigQuery Dataset: the dataset name only. The module’s billing_export_dataset output shows project:dataset, so drop the project and the colon.
    • GCP Project Number, Workload Identity Pool ID, Workload Identity Provider ID and Service Account Email: the module outputs.
  4. Save the connection.

Errors from Google’s token exchange are the same as for GCP. See the GCP troubleshooting table. A new pool or grant can take a minute or two to apply, and Plutus retries automatically during that time on a new connection.

Figures are net charges from your Cloud Billing export, after credits, grouped by SKU.

While Gemini API is connected, the GCP source leaves out the Gemini API service, so nothing is counted twice. Vertex AI stays under GCP.

Plutus reads the model name from the SKU description. Google doesn’t document that format as stable, so an unfamiliar SKU appears under its full SKU name instead of a guessed model.

Billing export data can lag by up to a day.