Table of Contents

Class CountTokensResponse

Namespace
Google.GenAI.Types
Assembly
Google.GenAI.dll

Response for counting tokens.

public record CountTokensResponse : IEquatable<CountTokensResponse>
Inheritance
CountTokensResponse
Implements
Inherited Members

Properties

CachedContentTokenCount

Number of tokens in the cached part of the prompt (the cached content).

[JsonPropertyName("cachedContentTokenCount")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? CachedContentTokenCount { get; set; }

Property Value

int?

SdkHttpResponse

Used to retain the full HTTP response.

[JsonPropertyName("sdkHttpResponse")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public HttpResponse? SdkHttpResponse { get; set; }

Property Value

HttpResponse

TotalTokens

Total number of tokens.

[JsonPropertyName("totalTokens")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? TotalTokens { get; set; }

Property Value

int?

Methods

FromJson(string, JsonSerializerOptions?)

Deserializes a JSON string to a CountTokensResponse object.

public static CountTokensResponse? FromJson(string jsonString, JsonSerializerOptions? options = null)

Parameters

jsonString string

The JSON string to deserialize.

options JsonSerializerOptions

Optional JsonSerializerOptions.

Returns

CountTokensResponse

The deserialized CountTokensResponse object, or null if deserialization fails.