Calculate Gemini API Cost from usageMetadata

Use the token counts from one completed generateContent response to estimate what that Standard text request cost.

Find and copy the usage object

  1. Open the final generateContent response JSON in your API client or app logs.
  2. Copy the object inside usageMetadata. Keep its token counts and any serviceTier or modality fields.
  3. Select the model that made the request, paste the object, and choose Calculate cost. When the full response includes a supported modelVersion, the calculator detects it.

Copying the usage object keeps prompt and response text out of the editor.

Example usageMetadata

Select Gemini 4 Neon before pasting this example.

{
  "promptTokenCount": 105000,
  "cachedContentTokenCount": 100000,
  "candidatesTokenCount": 1500,
  "thoughtsTokenCount": 500,
  "totalTokenCount": 107000
}

Expected estimate $0.0600

How the fields affect cost

  • Uncached input equals promptTokenCount minus cachedContentTokenCount. The prompt count already includes cached tokens.
  • Cache reads use cachedContentTokenCount at the model’s cache read rate.
  • Output includes both candidatesTokenCount and thoughtsTokenCount. Each part uses the output rate.

Each part has its own rate, so totalTokenCount alone cannot determine the cost. This calculator covers standard text generation. Check your billing dashboard for other service tiers, non-text requests, grounding, and explicit cache storage.

Gemini API usage field reference