Skip to content

GoogleTokenUsage

Namespace: Vercel.AI.Google

public sealed class GoogleTokenUsage

Token usage converted from Gemini usageMetadata.

Inheritance: object

View source

GoogleTokenUsage(int, int, int, int, int, int, JsonElement?)

Section titled “GoogleTokenUsage(int, int, int, int, int, int, JsonElement?)”
public GoogleTokenUsage(int inputTotal, int noCache, int cacheRead, int outputTotal, int text, int reasoning, JsonElement? raw)

Creates converted usage. CacheWrite stays null because Gemini does not report cache writes.

Parameters

Name Type Description
inputTotal int
noCache int
cacheRead int
outputTotal int
text int
reasoning int
raw JsonElement?

View source

public int CacheRead { get; }

Cached content tokens.

Value: int

View source

public int? CacheWrite { get; }

Always null. Gemini does not report cache writes.

Value: int?

View source

public int InputTotal { get; }

Prompt tokens plus tool-use prompt tokens.

Value: int

View source

public int NoCache { get; }

Input tokens that were not served from cache.

Value: int

View source

public int OutputTotal { get; }

Candidate tokens plus thought tokens.

Value: int

View source

public JsonElement? Raw { get; }

The original usage object.

Value: JsonElement?

View source

public int Reasoning { get; }

Thought tokens.

Value: int

View source

public int Text { get; }

Candidate tokens.

Value: int

View source

public LanguageModelUsage ToLanguageModelUsage()

Maps onto the shared usage type. Cache writes stay unset.

Returns: LanguageModelUsage

View source

Apache-2.0 · Copyright 2023 Vercel, Inc. · unofficial community port, not an official Vercel product