GenerateContentResponse

Response message for [PredictionService.GenerateContent].

Fields
candidates[] object (Candidate)

Output only. Generated candidates.

modelVersion string

Output only. The model version used to generate the response.

promptFeedback object (PromptFeedback)

Output only. Content filter results for a prompt sent in the request. Note: Sent only in the first stream chunk. Only happens when no candidates were generated due to content violations.

usageMetadata object (UsageMetadata)

Usage metadata about the response(s).

JSON representation
{
  "candidates": [
    {
      object (Candidate)
    }
  ],
  "modelVersion": string,
  "promptFeedback": {
    object (PromptFeedback)
  },
  "usageMetadata": {
    object (UsageMetadata)
  }
}

Candidate

A response candidate generated from the model.

Fields
index integer

Output only. Index of the candidate.

content object (Content)

Output only. Content parts of the candidate.

avgLogprobs number

Output only. Average log probability score of the candidate.

logprobsResult object (LogprobsResult)

Output only. log-likelihood scores for the response tokens and top tokens

finishReason enum (FinishReason)

Output only. The reason why the model stopped generating tokens. If empty, the model has not stopped generating the tokens.

safetyRatings[] object (SafetyRating)

Output only. List of ratings for the safety of a response candidate.

There is at most one rating per category.

citationMetadata object (CitationMetadata)

Output only. Source attribution of the generated content.

groundingMetadata object (GroundingMetadata)

Output only. metadata specifies sources used to ground generated content.

finishMessage string

Output only. Describes the reason the mode stopped generating tokens in more detail. This is only filled when finishReason is set.

JSON representation
{
  "index": integer,
  "content": {
    object (Content)
  },
  "avgLogprobs": number,
  "logprobsResult": {
    object (LogprobsResult)
  },
  "finishReason": enum (FinishReason),
  "safetyRatings": [
    {
      object (SafetyRating)
    }
  ],
  "citationMetadata": {
    object (CitationMetadata)
  },
  "groundingMetadata": {
    object (GroundingMetadata)
  },
  "finishMessage": string
}

LogprobsResult

Logprobs result

Fields
topCandidates[] object (TopCandidates)

Length = total number of decoding steps.

chosenCandidates[] object (Candidate)

Length = total number of decoding steps. The chosen candidates may or may not be in topCandidates.

JSON representation
{
  "topCandidates": [
    {
      object (TopCandidates)
    }
  ],
  "chosenCandidates": [
    {
      object (Candidate)
    }
  ]
}

TopCandidates

Candidates with top log probabilities at each decoding step.

Fields
candidates[] object (Candidate)

Sorted by log probability in descending order.

JSON representation
{
  "candidates": [
    {
      object (Candidate)
    }
  ]
}

Candidate

Candidate for the logprobs token and score.

Fields
token string

The candidate's token string value.

tokenId integer

The candidate's token id value.

logProbability number

The candidate's log probability.

JSON representation
{
  "token": string,
  "tokenId": integer,
  "logProbability": number
}

FinishReason

The reason why the model stopped generating tokens. If empty, the model has not stopped generating the tokens.

Enums
FINISH_REASON_UNSPECIFIED The finish reason is unspecified.
STOP token generation reached a natural stopping point or a configured stop sequence.
MAX_TOKENS token generation reached the configured maximum output tokens.
SAFETY token generation stopped because the content potentially contains safety violations. NOTE: When streaming, content is empty if content filters blocks the output.
RECITATION token generation stopped because the content potentially contains copyright violations.
OTHER All other reasons that stopped the token generation.
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.

SafetyRating

Safety rating corresponding to the generated content.

Fields
category enum (HarmCategory)

Output only. Harm category.

probability enum (HarmProbability)

Output only. Harm probability levels in the content.

probabilityScore number

Output only. Harm probability score.

severity enum (HarmSeverity)

Output only. Harm severity levels in the content.

severityScore number

Output only. Harm severity score.

blocked boolean

Output only. Indicates whether the content was filtered out because of this rating.

JSON representation
{
  "category": enum (HarmCategory),
  "probability": enum (HarmProbability),
  "probabilityScore": number,
  "severity": enum (HarmSeverity),
  "severityScore": number,
  "blocked": boolean
}

HarmProbability

Harm probability levels in the content.

Enums
HARM_PROBABILITY_UNSPECIFIED Harm probability unspecified.
NEGLIGIBLE Negligible level of harm.
LOW Low level of harm.
MEDIUM Medium level of harm.
HIGH High level of harm.

HarmSeverity

Harm severity levels.

Enums
HARM_SEVERITY_UNSPECIFIED Harm severity unspecified.
HARM_SEVERITY_NEGLIGIBLE Negligible level of harm severity.
HARM_SEVERITY_LOW Low level of harm severity.
HARM_SEVERITY_MEDIUM Medium level of harm severity.
HARM_SEVERITY_HIGH High level of harm severity.

CitationMetadata

A collection of source attributions for a piece of content.

Fields
citations[] object (Citation)

Output only. List of citations.

JSON representation
{
  "citations": [
    {
      object (Citation)
    }
  ]
}

Citation

Source attributions for content.

Fields
startIndex integer

Output only. Start index into the content.

endIndex integer

Output only. End index into the content.

uri string

Output only. url reference of the attribution.

title string

Output only. title of the attribution.

license string

Output only. License of the attribution.

publicationDate object (Date)

Output only. Publication date of the attribution.

JSON representation
{
  "startIndex": integer,
  "endIndex": integer,
  "uri": string,
  "title": string,
  "license": string,
  "publicationDate": {
    object (Date)
  }
}

GroundingMetadata

metadata returned to client when grounding is enabled.

Fields
webSearchQueries[] string

Optional. Web search queries for the following-up web search.

retrievalQueries[] string

Optional. Queries executed by the retrieval tools.

groundingChunks[] object (GroundingChunk)

List of supporting references retrieved from specified grounding source.

groundingSupports[] object (GroundingSupport)

Optional. List of grounding support.

searchEntryPoint object (SearchEntryPoint)

Optional. Google search entry for the following-up web searches.

retrievalMetadata object (RetrievalMetadata)

Optional. Output only. Retrieval metadata.

JSON representation
{
  "webSearchQueries": [
    string
  ],
  "retrievalQueries": [
    string
  ],
  "groundingChunks": [
    {
      object (GroundingChunk)
    }
  ],
  "groundingSupports": [
    {
      object (GroundingSupport)
    }
  ],
  "searchEntryPoint": {
    object (SearchEntryPoint)
  },
  "retrievalMetadata": {
    object (RetrievalMetadata)
  }
}

SearchEntryPoint

Google search entry point.

Fields
renderedContent string

Optional. Web content snippet that can be embedded in a web page or an app webview.

sdkBlob string (bytes format)

Optional. Base64 encoded JSON representing array of <search term, search url> tuple.

A base64-encoded string.

JSON representation
{
  "renderedContent": string,
  "sdkBlob": string
}

GroundingChunk

Grounding chunk.

Fields
Union field chunk_type. Chunk type. chunk_type can be only one of the following:
web object (Web)

Grounding chunk from the web.

retrievedContext object (RetrievedContext)

Grounding chunk from context retrieved by the retrieval tools.

JSON representation
{

  // Union field chunk_type can be only one of the following:
  "web": {
    object (Web)
  },
  "retrievedContext": {
    object (RetrievedContext)
  }
  // End of list of possible types for union field chunk_type.
}

Web

Chunk from the web.

Fields
uri string

URI reference of the chunk.

title string

title of the chunk.

JSON representation
{
  "uri": string,
  "title": string
}

RetrievedContext

Chunk from context retrieved by the retrieval tools.

Fields
uri string

URI reference of the attribution.

title string

title of the attribution.

JSON representation
{
  "uri": string,
  "title": string
}

GroundingSupport

Grounding support.

Fields
groundingChunkIndices[] integer

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[] number

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 object (Segment)

Segment of the content this support belongs to.

JSON representation
{
  "groundingChunkIndices": [
    integer
  ],
  "confidenceScores": [
    number
  ],
  "segment": {
    object (Segment)
  }
}

Segment

Segment of the content.

Fields
partIndex integer

Output only. The index of a Part object within its parent Content object.

startIndex integer

Output only. Start index in the given Part, measured in bytes. offset from the start of the Part, inclusive, starting at zero.

endIndex integer

Output only. End index in the given Part, measured in bytes. offset from the start of the Part, exclusive, starting at zero.

text string

Output only. The text corresponding to the segment from the response.

JSON representation
{
  "partIndex": integer,
  "startIndex": integer,
  "endIndex": integer,
  "text": string
}

RetrievalMetadata

metadata related to retrieval in the grounding flow.

Fields
googleSearchDynamicRetrievalScore number

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.

JSON representation
{
  "googleSearchDynamicRetrievalScore": number
}

PromptFeedback

Content filter results for a prompt sent in the request.

Fields
blockReason enum (BlockedReason)

Output only. Blocked reason.

safetyRatings[] object (SafetyRating)

Output only. Safety ratings.

blockReasonMessage string

Output only. A readable block reason message.

JSON representation
{
  "blockReason": enum (BlockedReason),
  "safetyRatings": [
    {
      object (SafetyRating)
    }
  ],
  "blockReasonMessage": string
}

BlockedReason

Blocked reason enumeration.

Enums
BLOCKED_REASON_UNSPECIFIED Unspecified blocked reason.
SAFETY Candidates blocked due to safety.
OTHER Candidates blocked due to other reason.
BLOCKLIST Candidates blocked due to the terms which are included from the terminology blocklist.
PROHIBITED_CONTENT Candidates blocked due to prohibited content.

UsageMetadata

Usage metadata about response(s).

Fields
promptTokenCount integer

Number of tokens in the request. When cachedContent is set, this is still the total effective prompt size meaning this includes the number of tokens in the cached content.

candidatesTokenCount integer

Number of tokens in the response(s).

totalTokenCount integer

Total token count for prompt and response candidates.

cachedContentTokenCount integer

Output only. Number of tokens in the cached part in the input (the cached content).

JSON representation
{
  "promptTokenCount": integer,
  "candidatesTokenCount": integer,
  "totalTokenCount": integer,
  "cachedContentTokenCount": integer
}