Skip to content

GoogleUsage

Namespace: Vercel.AI.Google

public static class GoogleUsage

Converts Gemini usageMetadata.

Inheritance: object

View source

public static JsonElement? Add(JsonElement? a, JsonElement? b)

Sums the usage metadata of two requests, such as the hops of a long decode response that was continued automatically. Numeric counts add, a missing count is the other side, and other fields come from <code class=“paramref”>b</code>.

Parameters

Name Type Description
a JsonElement?
b JsonElement?

Returns: JsonElement?

View source

public static GoogleTokenUsage? Convert(JsonElement? usage)

Adds tool-use prompt tokens to the input total and thought tokens to the output total. Returns null when <code class=“paramref”>usage</code> is missing.

Parameters

Name Type Description
usage JsonElement?

Returns: GoogleTokenUsage

View source

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