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.

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
  ],
  "retrievalQueries": [
    string
  ]
}
Fields
webSearchQueries[]

string

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

retrievalQueries[]

string

Optional. Queries executed by the retrieval tools.

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