LlmResponse

data class LlmResponse(val content: Content? = null, val usageMetadata: UsageMetadata? = null, val finishReason: FinishReason? = null, val errorMessage: String? = null, val partial: Boolean = false, val interrupted: Boolean = false, val modelVersion: String? = null, val citationMetadata: CitationMetadata? = null, val groundingMetadata: GroundingMetadata? = null, val errorCode: String? = null, val customMetadata: Map<String, Any?>? = null, val avgLogprobs: Double? = null, val logprobsResult: LogprobsResult? = null, val cacheMetadata: CacheMetadata? = null)

LLM response class that provides the first candidate response from the model if available. Otherwise, contains the error code and message.

Constructors

Link copied to clipboard
constructor(content: Content? = null, usageMetadata: UsageMetadata? = null, finishReason: FinishReason? = null, errorMessage: String? = null, partial: Boolean = false, interrupted: Boolean = false, modelVersion: String? = null, citationMetadata: CitationMetadata? = null, groundingMetadata: GroundingMetadata? = null, errorCode: String? = null, customMetadata: Map<String, Any?>? = null, avgLogprobs: Double? = null, logprobsResult: LogprobsResult? = null, cacheMetadata: CacheMetadata? = null)

Types

Link copied to clipboard
class Builder

Fluent builder for LlmResponse, provided primarily for Java callers. Any property left unset falls back to the same default as the constructor.

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
Link copied to clipboard

Context cache metadata for this response, populated when context caching is enabled. null when caching is disabled or no cache information is available.

Link copied to clipboard

The citation metadata of the response.

Link copied to clipboard

The generative content of the response. This should only contain content from the user or the model, and not any framework or system-generated data.

Link copied to clipboard

Optional key-value pairs labeling the response. The entire map must be JSON serializable.

Link copied to clipboard

Error code if the response is an error. The code varies by model.

Link copied to clipboard

Error message if the response is an error.

Link copied to clipboard

The finish reason of the response.

Link copied to clipboard

The grounding metadata of the response.

Link copied to clipboard

Flag indicating that LLM was interrupted when generating the content. Usually it's due to user interruption during a bidi streaming.

Link copied to clipboard
Link copied to clipboard

The model version used to generate the response.

Link copied to clipboard

Indicates whether the text content is part of an unfinished text stream. Only used for streaming mode and when the content is plain text.

Link copied to clipboard

The usage metadata of the LlmResponse.