- JSON representation
- Candidate
- FinishReason
- SafetyRating
- HarmProbability
- CitationMetadata
- CitationSource
- PromptFeedback
- BlockReason
- UsageMetadata
Response from the model supporting multiple candidates.
Note on safety ratings and content filtering. They are reported for both prompt in GenerateContentResponse.prompt_feedback
and for each candidate in finishReason
and in safetyRatings
. The API contract is that: - either all requested candidates are returned or no candidates at all - no candidates are returned only if there was something wrong with the prompt (see promptFeedback
) - feedback on each candidate is reported on 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. |
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 the 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. |
index |
Output only. Index of the candidate in the list of candidates. |
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 candidate content was flagged for safety reasons. |
RECITATION |
The candidate content was flagged for recitation reasons. |
OTHER |
Unknown reason. |
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? |
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. |
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 your prompt. |
safetyRatings[] |
Ratings for safety of the prompt. There is at most one rating per category. |
BlockReason
Specifies what was the reason why prompt was blocked.
Enums | |
---|---|
BLOCK_REASON_UNSPECIFIED |
Default value. This value is unused. |
SAFETY |
Prompt was blocked due to safety reasons. You can inspect safetyRatings to understand which safety category blocked it. |
OTHER |
Prompt was blocked due to unknown reasons. |
UsageMetadata
Metadata on the generation request's token usage.
JSON representation |
---|
{ "promptTokenCount": integer, "candidatesTokenCount": integer, "totalTokenCount": integer } |
Fields | |
---|---|
promptTokenCount |
Number of tokens in the prompt. When cachedContent is set, this is still the total effective prompt size. I.e. this includes the number of tokens in the cached content. |
candidatesTokenCount |
Total number of tokens across the generated candidates. |
totalTokenCount |
Total token count for the generation request (prompt + candidates). |