Table of Contents

Class GenerateContentConfig

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

Optional model configuration parameters. For more information, see Content generation parameters (https://cloud.google.com/vertex-ai/generative-ai/docs/multimodal/content-generation-parameters).

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

Properties

AudioTimestamp

If enabled, audio timestamp will be included in the request to the model.

[JsonPropertyName("audioTimestamp")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? AudioTimestamp { get; set; }

Property Value

bool?

CachedContent

Resource name of a context cache that can be used in subsequent requests.

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

Property Value

string

CandidateCount

Number of response variations to return.

[JsonPropertyName("candidateCount")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? CandidateCount { get; set; }

Property Value

int?

EnableEnhancedCivicAnswers

Enables enhanced civic answers. It may not be available for all models. This field is not supported in Gemini Enterprise Agent Platform.

[JsonPropertyName("enableEnhancedCivicAnswers")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? EnableEnhancedCivicAnswers { get; set; }

Property Value

bool?

FrequencyPenalty

Positive values penalize tokens that repeatedly appear in the generated text, increasing the probability of generating more diverse content.

[JsonPropertyName("frequencyPenalty")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? FrequencyPenalty { get; set; }

Property Value

double?

HttpOptions

Used to override HTTP request options.

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

Property Value

HttpOptions

ImageConfig

The image generation configuration.

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

Property Value

ImageConfig

Labels

Labels with user-defined metadata to break down billed charges.

[JsonPropertyName("labels")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Dictionary<string, string>? Labels { get; set; }

Property Value

Dictionary<string, string>

Logprobs

Number of top candidate tokens to return the log probabilities for at each generation step.

[JsonPropertyName("logprobs")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? Logprobs { get; set; }

Property Value

int?

MaxOutputTokens

Maximum number of tokens that can be generated in the response.

[JsonPropertyName("maxOutputTokens")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? MaxOutputTokens { get; set; }

Property Value

int?

MediaResolution

If specified, the media resolution specified will be used.

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

Property Value

MediaResolution?

ModelArmorConfig

Settings for prompt and response sanitization using the Model Armor service. If supplied, safety_settings must not be supplied.

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

Property Value

ModelArmorConfig

ModelSelectionConfig

Configuration for model selection.

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

Property Value

ModelSelectionConfig

PresencePenalty

Positive values penalize tokens that already appear in the generated text, increasing the probability of generating more diverse content.

[JsonPropertyName("presencePenalty")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? PresencePenalty { get; set; }

Property Value

double?

ResponseJsonSchema

Optional. Output schema of the generated response. This is an alternative to response_schema that accepts JSON Schema (https://json-schema.org/). If set, response_schema must be omitted, but response_mime_type is required. While the full JSON Schema may be sent, not all features are supported. Specifically, only the following properties are supported: - $id - $defs - $ref - $anchor - type - format - title - description - enum (for strings and numbers) - items - prefixItems - minItems - maxItems - minimum - maximum - anyOf - oneOf (interpreted the same as anyOf) - properties - additionalProperties - required The non-standard propertyOrdering property may also be set. Cyclic references are unrolled to a limited degree and, as such, may only be used within non-required properties. (Nullable properties are not sufficient.) If $ref is set on a sub-schema, no other properties, except for than those starting as a $, may be set.

[JsonPropertyName("responseJsonSchema")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public object? ResponseJsonSchema { get; set; }

Property Value

object

ResponseLogprobs

Whether to return the log probabilities of the tokens that were chosen by the model at each step.

[JsonPropertyName("responseLogprobs")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public bool? ResponseLogprobs { get; set; }

Property Value

bool?

ResponseMimeType

Output response mimetype of the generated candidate text. Supported mimetype: - text/plain: (default) Text output. - application/json: JSON response in the candidates. The model needs to be prompted to output the appropriate response type, otherwise the behavior is undefined.

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

Property Value

string

ResponseModalities

The requested modalities of the response. Represents the set of modalities that the model can return.

[JsonPropertyName("responseModalities")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string>? ResponseModalities { get; set; }

Property Value

List<string>

ResponseSchema

The Schema object allows the definition of input and output data types. These types can be objects, but also primitives and arrays. Represents a select subset of an OpenAPI 3.0 schema object (https://spec.openapis.org/oas/v3.0.3#schema). If set, a compatible response_mime_type must also be set. Compatible mimetypes: application/json: Schema for JSON response. If response_schema doesn't process your schema correctly, try using response_json_schema instead.

[JsonPropertyName("responseSchema")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Schema? ResponseSchema { get; set; }

Property Value

Schema

RoutingConfig

Configuration for model router requests.

[JsonPropertyName("routingConfig")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public GenerationConfigRoutingConfig? RoutingConfig { get; set; }

Property Value

GenerationConfigRoutingConfig

SafetySettings

Safety settings in the request to block unsafe content in the response.

[JsonPropertyName("safetySettings")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<SafetySetting>? SafetySettings { get; set; }

Property Value

List<SafetySetting>

Seed

When seed is fixed to a specific number, the model makes a best effort to provide the same response for repeated requests. By default, a random number is used.

[JsonPropertyName("seed")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public int? Seed { get; set; }

Property Value

int?

ServiceTier

The service tier to use for the request. For example, ServiceTier.FLEX.

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

Property Value

ServiceTier?

SpeechConfig

The speech generation configuration.

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

Property Value

SpeechConfig

StopSequences

List of strings that tells the model to stop generating text if one of the strings is encountered in the response.

[JsonPropertyName("stopSequences")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<string>? StopSequences { get; set; }

Property Value

List<string>

SystemInstruction

Instructions for the model to steer it toward better performance. For example, "Answer as concisely as possible" or "Don't use technical terms in your response".

[JsonPropertyName("systemInstruction")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public Content? SystemInstruction { get; set; }

Property Value

Content

Temperature

Value that controls the degree of randomness in token selection. Lower temperatures are good for prompts that require a less open-ended or creative response, while higher temperatures can lead to more diverse or creative results.

[JsonPropertyName("temperature")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? Temperature { get; set; }

Property Value

double?

ThinkingConfig

The thinking features configuration.

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

Property Value

ThinkingConfig

ToolConfig

Associates model output to a specific function call.

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

Property Value

ToolConfig

Tools

Code that enables the system to interact with external systems to perform an action outside of the knowledge and scope of the model.

[JsonPropertyName("tools")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public List<Tool>? Tools { get; set; }

Property Value

List<Tool>

TopK

For each token selection step, the top_k tokens with the highest probabilities are sampled. Then tokens are further filtered based on top_p with the final token selected using temperature sampling. Use a lower number for less random responses and a higher number for more random responses.

[JsonPropertyName("topK")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? TopK { get; set; }

Property Value

double?

TopP

Tokens are selected from the most to least probable until the sum of their probabilities equals this value. Use a lower value for less random responses and a higher value for more random responses.

[JsonPropertyName("topP")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public double? TopP { get; set; }

Property Value

double?

Methods

FromJson(string, JsonSerializerOptions?)

Deserializes a JSON string to a GenerateContentConfig object.

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

Parameters

jsonString string

The JSON string to deserialize.

options JsonSerializerOptions

Optional JsonSerializerOptions.

Returns

GenerateContentConfig

The deserialized GenerateContentConfig object, or null if deserialization fails.