Skip to main content
POST
Run Agent

Body

application/json
appName
string
required
userId
string
required
sessionId
string
required
newMessage
Content · object | null

Contains the multi-part content of a message.

streaming
boolean
default:false
stateDelta
Statedelta · object | null
functionCallEventId
string | null
invocationId
string | null

Response

Successful Response

author
string
required
modelVersion
string | null
content
Content · object | null

Contains the multi-part content of a message.

groundingMetadata
GroundingMetadata · object | null

Information for various kinds of grounding.

partial
boolean | null
turnComplete
boolean | null
turnCompleteReason
enum<string> | null

The reason why the turn is complete.

Available options:
TURN_COMPLETE_REASON_UNSPECIFIED,
MALFORMED_FUNCTION_CALL,
RESPONSE_REJECTED,
NEED_MORE_INPUT,
PROHIBITED_INPUT_CONTENT,
IMAGE_PROHIBITED_INPUT_CONTENT,
INPUT_TEXT_CONTAIN_PROMINENT_PERSON_PROHIBITED,
INPUT_IMAGE_CELEBRITY,
INPUT_IMAGE_PHOTO_REALISTIC_CHILD_PROHIBITED,
INPUT_TEXT_NCII_PROHIBITED,
INPUT_OTHER,
INPUT_IP_PROHIBITED,
BLOCKLIST,
UNSAFE_PROMPT_FOR_IMAGE_GENERATION,
GENERATED_IMAGE_SAFETY,
GENERATED_CONTENT_SAFETY,
GENERATED_AUDIO_SAFETY,
GENERATED_VIDEO_SAFETY,
GENERATED_CONTENT_PROHIBITED,
GENERATED_CONTENT_BLOCKLIST,
GENERATED_IMAGE_PROHIBITED,
GENERATED_IMAGE_CELEBRITY,
GENERATED_IMAGE_PROMINENT_PEOPLE_DETECTED_BY_REWRITER,
GENERATED_IMAGE_IDENTIFIABLE_PEOPLE,
GENERATED_IMAGE_MINORS,
OUTPUT_IMAGE_IP_PROHIBITED,
GENERATED_OTHER,
MAX_REGENERATION_REACHED
finishReason
enum<string> | null

Output only. The reason why the model stopped generating tokens.

If empty, the model has not stopped generating the tokens.

Available options:
FINISH_REASON_UNSPECIFIED,
STOP,
MAX_TOKENS,
SAFETY,
RECITATION,
LANGUAGE,
OTHER,
BLOCKLIST,
PROHIBITED_CONTENT,
SPII,
MALFORMED_FUNCTION_CALL,
IMAGE_SAFETY,
UNEXPECTED_TOOL_CALL,
IMAGE_PROHIBITED_CONTENT,
NO_IMAGE,
IMAGE_RECITATION,
IMAGE_OTHER
errorCode
string | null
errorMessage
string | null
interrupted
boolean | null
customMetadata
Custommetadata · object | null
usageMetadata
GenerateContentResponseUsageMetadata · object | null

Usage metadata about the content generation request and response.

This message provides a detailed breakdown of token usage and other relevant metrics. This data type is not supported in Gemini API.

liveSessionResumptionUpdate
LiveServerSessionResumptionUpdate · object | null

Update of the session resumption state.

Only sent if session_resumption was set in the connection config.

liveSessionId
string | null
goAway
LiveServerGoAway · object | null

Server will not be able to service client soon.

inputTranscription
Transcription · object | null

Audio transcription in Server Content.

outputTranscription
Transcription · object | null

Audio transcription in Server Content.

avgLogprobs
number | null
logprobsResult
LogprobsResult · object | null

The log probabilities of the tokens generated by the model.

This is useful for understanding the model's confidence in its predictions and for debugging. For example, you can use log probabilities to identify when the model is making a less confident prediction or to explore alternative responses that the model considered. A low log probability can also indicate that the model is "hallucinating" or generating factually incorrect information.

cacheMetadata
CacheMetadata · object | null

Metadata for context cache associated with LLM responses.

This class stores cache identification, usage tracking, and lifecycle information for a particular cache instance. It can be in two states:

  1. Active cache state: cache_name is set, all fields populated
  2. Fingerprint-only state: cache_name is None, only fingerprint and contents_count are set for prefix matching

Token counts (cached and total) are available in the LlmResponse.usage_metadata and should be accessed from there to avoid duplication.

Attributes: cache_name: The full resource name of the cached content (e.g., 'projects/123/locations/us-central1/cachedContents/456'). None when no active cache exists (fingerprint-only state). expire_time: Unix timestamp when the cache expires. None when no active cache exists. fingerprint: Hash of cacheable contents (instruction + tools + contents). Always present for prefix matching. invocations_used: Number of invocations this cache has been used for. None when no active cache exists. contents_count: Number of contents. When active cache exists, this is the count of cached contents. When no active cache exists, this is the total count of contents in the request. created_at: Unix timestamp when the cache was created. None when no active cache exists.

citationMetadata
CitationMetadata · object | null

Citation information when the model quotes another source.

interactionId
string | null
invocationId
string
default:""
actions
EventActions · object

Represents the actions attached to an event.

longRunningToolIds
string[] | null
branch
string | null
id
string
default:""
timestamp
number