### 📌 **Questions for the Google Gemini API Team**

Hello Google Gemini API Team,

I have concerns about token usage calculations and billing accuracy when using AI APIs. Previously, with OpenAI’s API, I experienced a significant discrepancy between the token count estimated in the Playground and the actual tokens billed, particularly when using images. I want to ensure that similar issues do not occur with Gemini API.

I would appreciate clarification on the following points:

  1. Discrepancy Between Playground Estimates and Actual Token Usage

    • In OpenAI’s API, there was a noticeable difference between the token estimate shown in the Playground and the actual tokens billed.
    • Does Gemini API ensure that the token usage shown in the Playground matches the actual tokens used during API calls?
    • Could there be situations where the actual billed tokens exceed the estimated token usage?
  2. Token Calculation for Image Inputs

    • In OpenAI’s API, image inputs resulted in unexpectedly high token usage. How does Gemini API calculate token usage for images?
    • Does image size, resolution, or color complexity impact the number of tokens used?
    • Or, is token consumption for image-based responses fixed regardless of image size and quality?
  3. Pre-estimating Actual Billing Costs

    • With OpenAI’s API, it was difficult to predict actual billing costs.
    • Is there a way to accurately estimate token usage before making an API request in Gemini API?
    • Does Gemini API provide a token cost simulation tool to predict billing before executing requests?
  4. Optimizing Token Usage

    • OpenAI’s API often led to unexpectedly high token consumption when generating long or complex responses.
    • Does Gemini API offer best practices to minimize unnecessary token consumption?
    • For example, would compressing images or using specific formats help reduce token usage?

I appreciate any insights you can provide to ensure efficient and predictable usage of the Gemini API.

Thank you.

HI @user1354,

Probably I may not cater to all the issues but here are few points worth pointing out:

Count tokens Doc: Understand and count tokens  |  Gemini API  |  Google AI for Developers this will help you to understand how many tokens are used before even sending to the api.

Image tokens Counting: With Gemini 2.0, image inputs with both dimensions <=384 pixels are counted as 258 tokens. Images larger in one or both dimensions are cropped and scaled as needed into tiles of 768x768 pixels, each counted as 258 tokens. Prior to Gemini 2.0, images used a fixed 258 tokens.

Audio and Video: Video and audio files are converted to tokens at the following fixed rates: video at 263 tokens per second and audio at 32 tokens per second.

Hope this helps. Cheers!

1 Like