Table of Contents

Class GenerateContentResponse

Namespace
Google.GenAI.Types
Assembly
Google.GenAI.dll

Response message for PredictionService.GenerateContent.

public record GenerateContentResponse : IEquatable<GenerateContentResponse>
Inheritance
GenerateContentResponse
Implements
Inherited Members

Properties

Candidates

Response variations returned by the model.

[JsonPropertyName("candidates")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<Candidate>? Candidates { get; set; }

Property Value

List<Candidate>

CodeExecutionResult

Returns the code execution result output from the first candidate's first result part. Returns null if no code execution result parts are present.

public string? CodeExecutionResult { get; }

Property Value

string

CreateTime

Timestamp when the request is made to the server.

[JsonPropertyName("createTime")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public DateTime? CreateTime { get; set; }

Property Value

DateTime?

ExecutableCode

Returns the executable code string from the first candidate's first executable code part. Returns null if no executable code parts are present.

public string? ExecutableCode { get; }

Property Value

string

FunctionCalls

Returns the list of function calls from the first candidate. Returns null if no function call parts are present.

public List<FunctionCall>? FunctionCalls { get; }

Property Value

List<FunctionCall>

ModelStatus

Output only. The current model status of this model. This field is not supported in Vertex AI.

[JsonPropertyName("modelStatus")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ModelStatus? ModelStatus { get; set; }

Property Value

ModelStatus

ModelVersion

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

[JsonPropertyName("modelVersion")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? ModelVersion { get; set; }

Property Value

string

Parts

Returns the parts from the first candidate's content. Returns null if there are no candidates or no content.

public List<Part>? Parts { get; }

Property Value

List<Part>

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.

[JsonPropertyName("promptFeedback")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public GenerateContentResponsePromptFeedback? PromptFeedback { get; set; }

Property Value

GenerateContentResponsePromptFeedback

ResponseId

Output only. response_id is used to identify each response. It is the encoding of the event_id.

[JsonPropertyName("responseId")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public string? ResponseId { get; set; }

Property Value

string

SdkHttpResponse

Used to retain the full HTTP response.

[JsonPropertyName("sdkHttpResponse")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public HttpResponse? SdkHttpResponse { get; set; }

Property Value

HttpResponse

Text

Returns the concatenation of all text parts from the first candidate. Non-text parts are ignored. Returns null if no text parts are present.

public string? Text { get; }

Property Value

string

UsageMetadata

Usage metadata about the response(s).

[JsonPropertyName("usageMetadata")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public GenerateContentResponseUsageMetadata? UsageMetadata { get; set; }

Property Value

GenerateContentResponseUsageMetadata

Methods

FromJson(string, JsonSerializerOptions?)

Deserializes a JSON string to a GenerateContentResponse object.

public static GenerateContentResponse? FromJson(string jsonString, JsonSerializerOptions? options = null)

Parameters

jsonString string

The JSON string to deserialize.

options JsonSerializerOptions

Optional JsonSerializerOptions.

Returns

GenerateContentResponse

The deserialized GenerateContentResponse object, or null if deserialization fails.