Response from the model supporting multiple candidate responses.
Safety ratings and content filtering are reported for both prompt in GenerateContentResponse.prompt_feedback and for each candidate in finishReason and in safetyRatings. The API: - Returns either all requested candidates or none of them - Returns no candidates at all only if there was something wrong with the prompt (check promptFeedback) - Reports feedback on each candidate in finishReason and safetyRatings.
| JSON representation |
|---|
{ "candidates": [ { object ( |
| Fields | |
|---|---|
candidates[] |
Candidate responses from the model. |
promptFeedback |
Returns the prompt's feedback related to the content filters. |
usageMetadata |
Output only. Metadata on the generation requests' token usage. |
modelVersion |
Output only. The model version used to generate the response. |
responseId |
Output only. responseId is used to identify each response. |
Candidate
A response candidate generated from the model.
| JSON representation |
|---|
{ "content": { object ( |
| Fields | |
|---|---|
content |
Output only. Generated content returned from the model. |
finishReason |
Optional. Output only. The reason why the model stopped generating tokens. If empty, the model has not stopped generating tokens. |
safetyRatings[] |
List of ratings for the safety of a response candidate. There is at most one rating per category. |
citationMetadata |
Output only. Citation information for model-generated candidate. This field may be populated with recitation information for any text included in the |
tokenCount |
Output only. Token count for this candidate. |
groundingAttributions[] |
Output only. Attribution information for sources that contributed to a grounded answer. This field is populated for |
groundingMetadata |
Output only. Grounding metadata for the candidate. This field is populated for |
avgLogprobs |
Output only. Average log probability score of the candidate. |
logprobsResult |
Output only. Log-likelihood scores for the response tokens and top tokens |
urlContextMetadata |
Output only. Metadata related to url context retrieval tool. |
index |
Output only. Index of the candidate in the list of response candidates. |
finishMessage |
Optional. Output only. Details the reason why the model stopped generating tokens. This is populated only when |
Content
The base structured datatype containing multi-part content of a message.
A Content includes a role field designating the producer of the Content and a parts field containing multi-part data that contains the content of the message turn.
| JSON representation |
|---|
{
"parts": [
{
object ( |
| Fields | |
|---|---|
parts[] |
Ordered |
role |
Optional. The producer of the content. Must be either 'user' or 'model'. Useful to set for multi-turn conversations, otherwise can be left blank or unset. |
Part
A datatype containing media that is part of a multi-part Content message.
A Part consists of data which has an associated datatype. A Part can only contain one of the accepted types in Part.data.
A Part must have a fixed IANA MIME type identifying the type and subtype of the media if the inlineData field is filled with raw bytes.
| JSON representation |
|---|
{ "thought": boolean, "thoughtSignature": string, "partMetadata": { object }, // Union field |
| Fields | |
|---|---|
thought |
Optional. Indicates if the part is thought from the model. |
thoughtSignature |
Optional. An opaque signature for the thought so it can be reused in subsequent requests. A base64-encoded string. |
partMetadata |
Custom metadata associated with the Part. Agents using genai.Part as content representation may need to keep track of the additional information. For example it can be name of a file/source from which the Part originates or a way to multiplex multiple Part streams. |
Union field
|
|
text |
Inline text. |
inlineData |
Inline media bytes. |
functionCall |
A predicted |
functionResponse |
The result output of a |
fileData |
URI based data. |
executableCode |
Code generated by the model that is meant to be executed. |
codeExecutionResult |
Result of executing the |
Union field metadata. Controls extra preprocessing of data. metadata can be only one of the following: |
|
videoMetadata |
Optional. Video metadata. The metadata should only be specified while the video data is presented in inlineData or fileData. |
Blob
Raw media bytes.
Text should not be sent as raw bytes, use the 'text' field.
| JSON representation |
|---|
{ "mimeType": string, "data": string } |
| Fields | |
|---|---|
mimeType |
The IANA standard MIME type of the source data. Examples: - image/png - image/jpeg If an unsupported MIME type is provided, an error will be returned. For a complete list of supported types, see Supported file formats. |
data |
Raw bytes for media formats. A base64-encoded string. |
FunctionCall
A predicted FunctionCall returned from the model that contains a string representing the FunctionDeclaration.name with the arguments and their values.
| JSON representation |
|---|
{ "id": string, "name": string, "args": { object } } |
| Fields | |
|---|---|
id |
Optional. The unique id of the function call. If populated, the client to execute the |
name |
Required. The name of the function to call. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. |
args |
Optional. The function parameters and values in JSON object format. |
FunctionResponse
The result output from a FunctionCall that contains a string representing the FunctionDeclaration.name and a structured JSON object containing any output from the function is used as context to the model. This should contain the result of aFunctionCall made based on model prediction.
| JSON representation |
|---|
{ "id": string, "name": string, "response": { object }, "parts": [ { object ( |
| Fields | |
|---|---|
id |
Optional. The id of the function call this response is for. Populated by the client to match the corresponding function call |
name |
Required. The name of the function to call. Must be a-z, A-Z, 0-9, or contain underscores and dashes, with a maximum length of 64. |
response |
Required. The function response in JSON object format. Callers can use any keys of their choice that fit the function's syntax to return the function output, e.g. "output", "result", etc. In particular, if the function call failed to execute, the response can have an "error" key to return error details to the model. |
parts[] |
Optional. Ordered |
willContinue |
Optional. Signals that function call continues, and more responses will be returned, turning the function call into a generator. Is only applicable to NON_BLOCKING function calls, is ignored otherwise. If set to false, future responses will not be considered. It is allowed to return empty |
scheduling |
Optional. Specifies how the response should be scheduled in the conversation. Only applicable to NON_BLOCKING function calls, is ignored otherwise. Defaults to WHEN_IDLE. |
FunctionResponsePart
A datatype containing media that is part of a FunctionResponse message.
A FunctionResponsePart consists of data which has an associated datatype. A FunctionResponsePart can only contain one of the accepted types in FunctionResponsePart.data.
A FunctionResponsePart must have a fixed IANA MIME type identifying the type and subtype of the media if the inlineData field is filled with raw bytes.
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field data. The data of the function response part. data can be only one of the following: |
|
inlineData |
Inline media bytes. |
FunctionResponseBlob
Raw media bytes for function response.
Text should not be sent as raw bytes, use the 'FunctionResponse.response' field.
| JSON representation |
|---|
{ "mimeType": string, "data": string } |
| Fields | |
|---|---|
mimeType |
The IANA standard MIME type of the source data. Examples: - image/png - image/jpeg If an unsupported MIME type is provided, an error will be returned. For a complete list of supported types, see Supported file formats. |
data |
Raw bytes for media formats. A base64-encoded string. |
Scheduling
Specifies how the response should be scheduled in the conversation.
| Enums | |
|---|---|
SCHEDULING_UNSPECIFIED |
This value is unused. |
SILENT |
Only add the result to the conversation context, do not interrupt or trigger generation. |
WHEN_IDLE |
Add the result to the conversation context, and prompt to generate output without interrupting ongoing generation. |
INTERRUPT |
Add the result to the conversation context, interrupt ongoing generation and prompt to generate output. |
FileData
URI based data.
| JSON representation |
|---|
{ "mimeType": string, "fileUri": string } |
| Fields | |
|---|---|
mimeType |
Optional. The IANA standard MIME type of the source data. |
fileUri |
Required. URI. |
ExecutableCode
Code generated by the model that is meant to be executed, and the result returned to the model.
Only generated when using the CodeExecution tool, in which the code will be automatically executed, and a corresponding CodeExecutionResult will also be generated.
| JSON representation |
|---|
{
"language": enum ( |
| Fields | |
|---|---|
language |
Required. Programming language of the |
code |
Required. The code to be executed. |
Language
Supported programming languages for the generated code.
| Enums | |
|---|---|
LANGUAGE_UNSPECIFIED |
Unspecified language. This value should not be used. |
PYTHON |
Python >= 3.10, with numpy and simpy available. Python is the default language. |
CodeExecutionResult
Result of executing the ExecutableCode.
Only generated when using the CodeExecution, and always follows a part containing the ExecutableCode.
| JSON representation |
|---|
{
"outcome": enum ( |
| Fields | |
|---|---|
outcome |
Required. Outcome of the code execution. |
output |
Optional. Contains stdout when code execution is successful, stderr or other description otherwise. |
Outcome
Enumeration of possible outcomes of the code execution.
| Enums | |
|---|---|
OUTCOME_UNSPECIFIED |
Unspecified status. This value should not be used. |
OUTCOME_OK |
Code execution completed successfully. |
OUTCOME_FAILED |
Code execution finished but with a failure. stderr should contain the reason. |
OUTCOME_DEADLINE_EXCEEDED |
Code execution ran for too long, and was cancelled. There may or may not be a partial output present. |
VideoMetadata
Metadata describes the input video content.
| JSON representation |
|---|
{ "startOffset": string, "endOffset": string, "fps": number } |
| Fields | |
|---|---|
startOffset |
Optional. The start offset of the video. A duration in seconds with up to nine fractional digits, ending with ' |
endOffset |
Optional. The end offset of the video. A duration in seconds with up to nine fractional digits, ending with ' |
fps |
Optional. The frame rate of the video sent to the model. If not specified, the default value will be 1.0. The fps range is (0.0, 24.0]. |
FinishReason
Defines the reason why the model stopped generating tokens.
| Enums | |
|---|---|
FINISH_REASON_UNSPECIFIED |
Default value. This value is unused. |
STOP |
Natural stop point of the model or provided stop sequence. |
MAX_TOKENS |
The maximum number of tokens as specified in the request was reached. |
SAFETY |
The response candidate content was flagged for safety reasons. |
RECITATION |
The response candidate content was flagged for recitation reasons. |
LANGUAGE |
The response candidate content was flagged for using an unsupported language. |
OTHER |
Unknown reason. |
BLOCKLIST |
Token generation stopped because the content contains forbidden terms. |
PROHIBITED_CONTENT |
Token generation stopped for potentially containing prohibited content. |
SPII |
Token generation stopped because the content potentially contains Sensitive Personally Identifiable Information (SPII). |
MALFORMED_FUNCTION_CALL |
The function call generated by the model is invalid. |
IMAGE_SAFETY |
Token generation stopped because generated images contain safety violations. |
IMAGE_PROHIBITED_CONTENT |
Image generation stopped because generated images has other prohibited content. |
IMAGE_OTHER |
Image generation stopped because of other miscellaneous issue. |
NO_IMAGE |
The model was expected to generate an image, but none was generated. |
IMAGE_RECITATION |
Image generation stopped due to recitation. |
UNEXPECTED_TOOL_CALL |
Model generated a tool call but no tools were enabled in the request. |
TOO_MANY_TOOL_CALLS |
Model called too many tools consecutively, thus the system exited execution. |
SafetyRating
Safety rating for a piece of content.
The safety rating contains the category of harm and the harm probability level in that category for a piece of content. Content is classified for safety across a number of harm categories and the probability of the harm classification is included here.
| JSON representation |
|---|
{ "category": enum ( |
| Fields | |
|---|---|
category |
Required. The category for this rating. |
probability |
Required. The probability of harm for this content. |
blocked |
Was this content blocked because of this rating? |
HarmCategory
The category of a rating.
These categories cover various kinds of harms that developers may wish to adjust.
| Enums | |
|---|---|
HARM_CATEGORY_UNSPECIFIED |
Category is unspecified. |
HARM_CATEGORY_DEROGATORY |
PaLM - Negative or harmful comments targeting identity and/or protected attribute. |
HARM_CATEGORY_TOXICITY |
PaLM - Content that is rude, disrespectful, or profane. |
HARM_CATEGORY_VIOLENCE |
PaLM - Describes scenarios depicting violence against an individual or group, or general descriptions of gore. |
HARM_CATEGORY_SEXUAL |
PaLM - Contains references to sexual acts or other lewd content. |
HARM_CATEGORY_MEDICAL |
PaLM - Promotes unchecked medical advice. |
HARM_CATEGORY_DANGEROUS |
PaLM - Dangerous content that promotes, facilitates, or encourages harmful acts. |
HARM_CATEGORY_HARASSMENT |
Gemini - Harassment content. |
HARM_CATEGORY_HATE_SPEECH |
Gemini - Hate speech and content. |
HARM_CATEGORY_SEXUALLY_EXPLICIT |
Gemini - Sexually explicit content. |
HARM_CATEGORY_DANGEROUS_CONTENT |
Gemini - Dangerous content. |
HARM_CATEGORY_CIVIC_INTEGRITY |
Gemini - Content that may be used to harm civic integrity. DEPRECATED: use enableEnhancedCivicAnswers instead. |
HarmProbability
The probability that a piece of content is harmful.
The classification system gives the probability of the content being unsafe. This does not indicate the severity of harm for a piece of content.
| Enums | |
|---|---|
HARM_PROBABILITY_UNSPECIFIED |
Probability is unspecified. |
NEGLIGIBLE |
Content has a negligible chance of being unsafe. |
LOW |
Content has a low chance of being unsafe. |
MEDIUM |
Content has a medium chance of being unsafe. |
HIGH |
Content has a high chance of being unsafe. |
CitationMetadata
A collection of source attributions for a piece of content.
| JSON representation |
|---|
{
"citationSources": [
{
object ( |
| Fields | |
|---|---|
citationSources[] |
Citations to sources for a specific response. |
CitationSource
A citation to a source for a portion of a specific response.
| JSON representation |
|---|
{ "startIndex": integer, "endIndex": integer, "uri": string, "license": string } |
| Fields | |
|---|---|
startIndex |
Optional. Start of segment of the response that is attributed to this source. Index indicates the start of the segment, measured in bytes. |
endIndex |
Optional. End of the attributed segment, exclusive. |
uri |
Optional. URI that is attributed as a source for a portion of the text. |
license |
Optional. License for the GitHub project that is attributed as a source for segment. License info is required for code citations. |
GroundingAttribution
Attribution for a source that contributed to an answer.
| JSON representation |
|---|
{ "sourceId": { object ( |
| Fields | |
|---|---|
sourceId |
Output only. Identifier for the source contributing to this attribution. |
content |
Grounding source content that makes up this attribution. |
AttributionSourceId
Identifier for the source contributing to this attribution.
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field
|
|
groundingPassage |
Identifier for an inline passage. |
semanticRetrieverChunk |
Identifier for a |
GroundingPassageId
Identifier for a part within a GroundingPassage.
| JSON representation |
|---|
{ "passageId": string, "partIndex": integer } |
| Fields | |
|---|---|
passageId |
Output only. ID of the passage matching the |
partIndex |
Output only. Index of the part within the |
SemanticRetrieverChunk
Identifier for a Chunk retrieved via Semantic Retriever specified in the GenerateAnswerRequest using SemanticRetrieverConfig.
| JSON representation |
|---|
{ "source": string, "chunk": string } |
| Fields | |
|---|---|
source |
Output only. Name of the source matching the request's |
chunk |
Output only. Name of the |
GroundingMetadata
Metadata returned to client when grounding is enabled.
| JSON representation |
|---|
{ "groundingChunks": [ { object ( |
| Fields | |
|---|---|
groundingChunks[] |
List of supporting references retrieved from specified grounding source. |
groundingSupports[] |
List of grounding support. |
webSearchQueries[] |
Web search queries for the following-up web search. |
searchEntryPoint |
Optional. Google search entry for the following-up web searches. |
retrievalMetadata |
Metadata related to retrieval in the grounding flow. |
googleMapsWidgetContextToken |
Optional. Resource name of the Google Maps widget context token that can be used with the PlacesContextElement widget in order to render contextual data. Only populated in the case that grounding with Google Maps is enabled. |
SearchEntryPoint
Google search entry point.
| JSON representation |
|---|
{ "renderedContent": string, "sdkBlob": string } |
| Fields | |
|---|---|
renderedContent |
Optional. Web content snippet that can be embedded in a web page or an app webview. |
sdkBlob |
Optional. Base64 encoded JSON representing array of <search term, search url> tuple. A base64-encoded string. |
GroundingChunk
Grounding chunk.
| JSON representation |
|---|
{ // Union field |
| Fields | |
|---|---|
Union field chunk_type. Chunk type. chunk_type can be only one of the following: |
|
web |
Grounding chunk from the web. |
retrievedContext |
Optional. Grounding chunk from context retrieved by the file search tool. |
maps |
Optional. Grounding chunk from Google Maps. |
Web
Chunk from the web.
| JSON representation |
|---|
{ "uri": string, "title": string } |
| Fields | |
|---|---|
uri |
URI reference of the chunk. |
title |
Title of the chunk. |
RetrievedContext
Chunk from context retrieved by the file search tool.
| JSON representation |
|---|
{ "uri": string, "title": string, "text": string, "fileSearchStore": string } |
| Fields | |
|---|---|
uri |
Optional. URI reference of the semantic retrieval document. |
title |
Optional. Title of the document. |
text |
Optional. Text of the chunk. |
fileSearchStore |
Optional. Name of the |
Maps
A grounding chunk from Google Maps. A Maps chunk corresponds to a single place.
| JSON representation |
|---|
{
"uri": string,
"title": string,
"text": string,
"placeId": string,
"placeAnswerSources": {
object ( |
| Fields | |
|---|---|
uri |
URI reference of the place. |
title |
Title of the place. |
text |
Text description of the place answer. |
placeId |
This ID of the place, in |
placeAnswerSources |
Sources that provide answers about the features of a given place in Google Maps. |
PlaceAnswerSources
Collection of sources that provide answers about the features of a given place in Google Maps. Each PlaceAnswerSources message corresponds to a specific place in Google Maps. The Google Maps tool used these sources in order to answer questions about features of the place (e.g: "does Bar Foo have Wifi" or "is Foo Bar wheelchair accessible?"). Currently we only support review snippets as sources.
| JSON representation |
|---|
{
"reviewSnippets": [
{
object ( |
| Fields | |
|---|---|
reviewSnippets[] |
Snippets of reviews that are used to generate answers about the features of a given place in Google Maps. |
ReviewSnippet
Encapsulates a snippet of a user review that answers a question about the features of a specific place in Google Maps.
| JSON representation |
|---|
{ "reviewId": string, "googleMapsUri": string, "title": string } |
| Fields | |
|---|---|
reviewId |
The ID of the review snippet. |
googleMapsUri |
A link that corresponds to the user review on Google Maps. |
title |
Title of the review. |
GroundingSupport
Grounding support.
| JSON representation |
|---|
{
"groundingChunkIndices": [
integer
],
"confidenceScores": [
number
],
"segment": {
object ( |
| Fields | |
|---|---|
groundingChunkIndices[] |
A list of indices (into 'grounding_chunk') specifying the citations associated with the claim. For instance [1,3,4] means that grounding_chunk[1], grounding_chunk[3], grounding_chunk[4] are the retrieved content attributed to the claim. |
confidenceScores[] |
Confidence score of the support references. Ranges from 0 to 1. 1 is the most confident. This list must have the same size as the groundingChunkIndices. |
segment |
Segment of the content this support belongs to. |
Segment
Segment of the content.
| JSON representation |
|---|
{ "partIndex": integer, "startIndex": integer, "endIndex": integer, "text": string } |
| Fields | |
|---|---|
partIndex |
Output only. The index of a Part object within its parent Content object. |
startIndex |
Output only. Start index in the given Part, measured in bytes. Offset from the start of the Part, inclusive, starting at zero. |
endIndex |
Output only. End index in the given Part, measured in bytes. Offset from the start of the Part, exclusive, starting at zero. |
text |
Output only. The text corresponding to the segment from the response. |
RetrievalMetadata
Metadata related to retrieval in the grounding flow.
| JSON representation |
|---|
{ "googleSearchDynamicRetrievalScore": number } |
| Fields | |
|---|---|
googleSearchDynamicRetrievalScore |
Optional. Score indicating how likely information from google search could help answer the prompt. The score is in the range [0, 1], where 0 is the least likely and 1 is the most likely. This score is only populated when google search grounding and dynamic retrieval is enabled. It will be compared to the threshold to determine whether to trigger google search. |
LogprobsResult
Logprobs Result
| JSON representation |
|---|
{ "topCandidates": [ { object ( |
| Fields | |
|---|---|
topCandidates[] |
Length = total number of decoding steps. |
chosenCandidates[] |
Length = total number of decoding steps. The chosen candidates may or may not be in topCandidates. |
logProbabilitySum |
Sum of log probabilities for all tokens. |
TopCandidates
Candidates with top log probabilities at each decoding step.
| JSON representation |
|---|
{
"candidates": [
{
object ( |
| Fields | |
|---|---|
candidates[] |
Sorted by log probability in descending order. |
Candidate
Candidate for the logprobs token and score.
| JSON representation |
|---|
{ "token": string, "tokenId": integer, "logProbability": number } |
| Fields | |
|---|---|
token |
The candidate’s token string value. |
tokenId |
The candidate’s token id value. |
logProbability |
The candidate's log probability. |
UrlContextMetadata
Metadata related to url context retrieval tool.
| JSON representation |
|---|
{
"urlMetadata": [
{
object ( |
| Fields | |
|---|---|
urlMetadata[] |
List of url context. |
UrlMetadata
Context of the a single url retrieval.
| JSON representation |
|---|
{
"retrievedUrl": string,
"urlRetrievalStatus": enum ( |
| Fields | |
|---|---|
retrievedUrl |
Retrieved url by the tool. |
urlRetrievalStatus |
Status of the url retrieval. |
UrlRetrievalStatus
Status of the url retrieval.
| Enums | |
|---|---|
URL_RETRIEVAL_STATUS_UNSPECIFIED |
Default value. This value is unused. |
URL_RETRIEVAL_STATUS_SUCCESS |
Url retrieval is successful. |
URL_RETRIEVAL_STATUS_ERROR |
Url retrieval is failed due to error. |
URL_RETRIEVAL_STATUS_PAYWALL |
Url retrieval is failed because the content is behind paywall. |
URL_RETRIEVAL_STATUS_UNSAFE |
Url retrieval is failed because the content is unsafe. |
PromptFeedback
A set of the feedback metadata the prompt specified in GenerateContentRequest.content.
| JSON representation |
|---|
{ "blockReason": enum ( |
| Fields | |
|---|---|
blockReason |
Optional. If set, the prompt was blocked and no candidates are returned. Rephrase the prompt. |
safetyRatings[] |
Ratings for safety of the prompt. There is at most one rating per category. |
BlockReason
Specifies the reason why the prompt was blocked.
| Enums | |
|---|---|
BLOCK_REASON_UNSPECIFIED |
Default value. This value is unused. |
SAFETY |
Prompt was blocked due to safety reasons. Inspect safetyRatings to understand which safety category blocked it. |
OTHER |
Prompt was blocked due to unknown reasons. |
BLOCKLIST |
Prompt was blocked due to the terms which are included from the terminology blocklist. |
PROHIBITED_CONTENT |
Prompt was blocked due to prohibited content. |
IMAGE_SAFETY |
Candidates blocked due to unsafe image generation content. |
UsageMetadata
Metadata on the generation request's token usage.
| JSON representation |
|---|
{ "promptTokenCount": integer, "cachedContentTokenCount": integer, "candidatesTokenCount": integer, "toolUsePromptTokenCount": integer, "thoughtsTokenCount": integer, "totalTokenCount": integer, "promptTokensDetails": [ { object ( |
| Fields | |
|---|---|
promptTokenCount |
Number of tokens in the prompt. When |
cachedContentTokenCount |
Number of tokens in the cached part of the prompt (the cached content) |
candidatesTokenCount |
Total number of tokens across all the generated response candidates. |
toolUsePromptTokenCount |
Output only. Number of tokens present in tool-use prompt(s). |
thoughtsTokenCount |
Output only. Number of tokens of thoughts for thinking models. |
totalTokenCount |
Total token count for the generation request (prompt + response candidates). |
promptTokensDetails[] |
Output only. List of modalities that were processed in the request input. |
cacheTokensDetails[] |
Output only. List of modalities of the cached content in the request input. |
candidatesTokensDetails[] |
Output only. List of modalities that were returned in the response. |
toolUsePromptTokensDetails[] |
Output only. List of modalities that were processed for tool-use request inputs. |
ModalityTokenCount
Represents token counting info for a single modality.
| JSON representation |
|---|
{
"modality": enum ( |
| Fields | |
|---|---|
modality |
The modality associated with this token count. |
tokenCount |
Number of tokens. |
Modality
Content Part modality
| Enums | |
|---|---|
MODALITY_UNSPECIFIED |
Unspecified modality. |
TEXT |
Plain text. |
IMAGE |
Image. |
VIDEO |
Video. |
AUDIO |
Audio. |
DOCUMENT |
Document, e.g. PDF. |