GenerateContentResponse

Response message for [PredictionService.GenerateContent].

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

object (Candidate)

Output only. Generated candidates.

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).

Candidate

A response candidate generated from the model.

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

integer

Output only. Index of the candidate.

content

object (Content)

Output only. Content parts of the candidate.

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.

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 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 token generation was stopped as the response was flagged for safety reasons. NOTE: When streaming the Candidate.content will be empty if content filters blocked the output.
RECITATION The token generation was stopped as the response was flagged for unauthorized citations.
OTHER All other reasons that stopped the token generation
BLOCKLIST The token generation was stopped as the response was flagged for the terms which are included from the terminology blocklist.
PROHIBITED_CONTENT The token generation was stopped as the response was flagged for the prohibited contents.
SPII The token generation was stopped as the response was flagged for Sensitive Personally Identifiable Information (SPII) contents.
MALFORMED_FUNCTION_CALL The function call generated by the model is invalid.

SafetyRating

Safety rating corresponding to the generated content.

JSON representation
{
  "category": enum (HarmCategory),
  "probability": enum (HarmProbability),
  "probabilityScore": number,
  "severity": enum (HarmSeverity),
  "severityScore": number,
  "blocked": boolean
}
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.

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.

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

object (Citation)

Output only. List of citations.

Citation

Source attributions for content.

JSON representation
{
  "startIndex": integer,
  "endIndex": integer,
  "uri": string,
  "title": string,
  "license": string,
  "publicationDate": {
    object (Date)
  }
}
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.

GroundingMetadata

metadata returned to client when grounding is enabled.

JSON representation
{
  "webSearchQueries": [
    string
  ],
  "groundingAttributions": [
    {
      object (GroundingAttribution)
    }
  ],
  "groundingChunks": [
    {
      object (GroundingChunk)
    }
  ],
  "groundingSupports": [
    {
      object (GroundingSupport)
    }
  ],
  "searchEntryPoint": {
    object (SearchEntryPoint)
  }
}
Fields
webSearchQueries[]

string

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

groundingAttributions[]

object (GroundingAttribution)

Optional. List of grounding attributions.

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.

SearchEntryPoint

Google search entry point.

JSON representation
{
  "renderedContent": string,
  "sdkBlob": string
}
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.

GroundingAttribution

Grounding attribution.

JSON representation
{
  "segment": {
    object (Segment)
  },

  // Union field reference can be only one of the following:
  "web": {
    object (Web)
  }
  // End of list of possible types for union field reference.
  "confidenceScore": number
}
Fields
segment

object (Segment)

Output only. Segment of the content this attribution belongs to.

Union field reference.

reference can be only one of the following:

web

object (Web)

Optional. Attribution from the web.

confidenceScore

number

Optional. Output only. confidence score of the attribution. Ranges from 0 to 1. 1 is the most confident.

Web

Attribution from the web.

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

string

Output only. URI reference of the attribution.

title

string

Output only. title of the attribution.

Segment

Segment of the content.

JSON representation
{
  "partIndex": integer,
  "startIndex": integer,
  "endIndex": integer,
  "text": string
}
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.

GroundingChunk

Grounding chunk.

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.
}
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.

Web

Chunk from the web.

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

string

URI reference of the chunk.

title

string

title of the chunk.

RetrievedContext

Chunk from context retrieved by the retrieval tools.

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

string

URI reference of the attribution.

title

string

title of the attribution.

GroundingSupport

Grounding support.

JSON representation
{
  "groundingChunkIndices": [
    integer
  ],
  "confidenceScores": [
    number
  ],
  "segment": {
    object (Segment)
  }
}
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.

PromptFeedback

Content filter results for a prompt sent in the request.

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

enum (BlockedReason)

Output only. Blocked reason.

safetyRatings[]

object (SafetyRating)

Output only. Safety ratings.

blockReasonMessage

string

Output only. A readable block reason message.

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).

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

integer

Number of tokens in the request.

candidatesTokenCount

integer

Number of tokens in the response(s).

totalTokenCount

integer