Table of Contents

Class GenerateContentResponse

Namespace
GenerativeAI.Types
Assembly
GenerativeAI.dll

Response from the model supporting multiple candidate responses. Safety ratings and content filtering are reported for both prompt in PromptFeedback 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.
public class GenerateContentResponse
Inheritance
GenerateContentResponse
Inherited Members
Extension Methods

Properties

Candidates

Candidate responses from the model.

[JsonPropertyName("candidates")]
public Candidate[]? Candidates { get; set; }

Property Value

Candidate[]

CreateTime

Output only. Creation time of the response. Uses RFC 3339, where generated output will always be Z-normalized and uses 0, 3, 6 or 9 fractional digits.

[JsonPropertyName("createTime")]
public Timestamp? CreateTime { get; set; }

Property Value

Timestamp

ModelStatus

Lifecycle status of the model that served the request, including deprecation and retirement information.

[JsonPropertyName("modelStatus")]
public ModelStatus? ModelStatus { get; set; }

Property Value

ModelStatus

ModelVersion

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

[JsonPropertyName("modelVersion")]
public string? ModelVersion { get; set; }

Property Value

string

PromptFeedback

Returns the prompt's feedback related to the content filters.

[JsonPropertyName("promptFeedback")]
public PromptFeedback? PromptFeedback { get; set; }

Property Value

PromptFeedback

ResponseId

Output only. A unique identifier for the response.

[JsonPropertyName("responseId")]
public string? ResponseId { get; set; }

Property Value

string

Text

Gets the text content from the last candidate's response parts, joined by newlines.

public string Text { get; }

Property Value

string

UsageMetadata

Output only. Metadata on the generation requests' token usage.

[JsonPropertyName("usageMetadata")]
public UsageMetadata? UsageMetadata { get; set; }

Property Value

UsageMetadata

Methods

ToString()

Converts the GenerateContentResponse instance to its string representation.

public override string ToString()

Returns

string

A formatted string displaying the properties of the object.

Operators

explicit operator string(GenerateContentResponse)

Converts the GenerateContentResponse instance to its string representation explicitly.

public static explicit operator string(GenerateContentResponse response)

Parameters

response GenerateContentResponse

The GenerateContentResponse instance to convert.

Returns

string

A string that represents the content of the GenerateContentResponse instance.

See Also