I'm using Vertex AI's generative model API, and after a request it returns two fields: totalTokens
and totalBillableCharacters
. According to the Gemini Flash 2.0 Lite
pricing page, input tokens cost $0.075 per 1M tokens and output text tokens cost $0.30 per 1M tokens.
However, I'm confused about the relationship between these four terms:
totalTokens
totalBillableCharacters
(because I send an image asbase64 string
for analysis)- Input tokens
- Output text tokens
Specifically:
- How do
totalTokens
andtotalBillableCharacters
relate to input tokens and output text tokens? - Given the pricing, how can I calculate the total monetary cost for a request if I only have the API's
totalTokens
andtotalBillableCharacters
?
For example, if my API call returns a combined token count, how can I determine the number of input tokens versus output tokens, and then apply the pricing rates to compute the cost?
Any guidance or code examples for converting these token counts to a dollar amount would be appreciated.