Class GenerationConfig
- Namespace
- GenerativeAI.Types
- Assembly
- GenerativeAI.dll
Configuration options for model generation and outputs. Not all parameters are configurable for every model.
public class GenerationConfig
- Inheritance
-
GenerationConfig
- Inherited Members
- Extension Methods
Properties
AudioTimestamp
Optional. If enabled, audio timestamp will be included in the request to the model.
[JsonPropertyName("audioTimestamp")]
public bool? AudioTimestamp { get; set; }
Property Value
- bool?
AudioTranscriptionConfig
Speech recognition settings for audio input, such as language codes, custom vocabulary and diarization.
[JsonPropertyName("audioTranscriptionConfig")]
public AudioTranscriptionConfig? AudioTranscriptionConfig { get; set; }
Property Value
CandidateCount
Optional. Number of generated responses to return. Currently, this value can only be set to 1. If unset, this will default to 1.
[JsonPropertyName("candidateCount")]
public int? CandidateCount { get; set; }
Property Value
- int?
EnableAffectiveDialog
Optional. If enabled, the model will detect emotions and adapt its responses accordingly.
[JsonPropertyName("enableAffectiveDialog")]
public bool? EnableAffectiveDialog { get; set; }
Property Value
- bool?
EnableEnhancedCivicAnswers
Optional. Enables enhanced civic answers. It may not be available for all models.
[JsonPropertyName("enableEnhancedCivicAnswers")]
public bool? EnableEnhancedCivicAnswers { get; set; }
Property Value
- bool?
FrequencyPenalty
Optional. Frequency penalty applied to the next token's logprobs, multiplied by the number of times each token has been seen in the response so far. A positive penalty will discourage the use of tokens that have already been used, proportional to the number of times the token has been used: The more a token is used, the more difficult it is for the model to use that token again, increasing the vocabulary of responses. Caution: A negative penalty will encourage the model to reuse tokens proportional to the number of times the token has been used. Small negative values will reduce the vocabulary of a response. Larger negative values will cause the model to start repeating a common token until it hits the MaxOutputTokens limit.
[JsonPropertyName("frequencyPenalty")]
public double? FrequencyPenalty { get; set; }
Property Value
ImageConfig
Optional. Image generation configuration for models that support image output.
[JsonPropertyName("imageConfig")]
public ImageConfig? ImageConfig { get; set; }
Property Value
Logprobs
Optional. Only valid if ResponseLogprobs is True. This sets the number of top logprobs to return at each decoding step in the LogprobsResult.
[JsonPropertyName("logprobs")]
public int? Logprobs { get; set; }
Property Value
- int?
MaxOutputTokens
Optional. The maximum number of tokens to include in a response candidate.
Note: The default value varies by model, see the Model.output_token_limit
attribute of the Model returned from the getModel function.
[JsonPropertyName("maxOutputTokens")]
public int? MaxOutputTokens { get; set; }
Property Value
- int?
MediaResolution
Optional. If specified, the media resolution specified will be used.
[JsonPropertyName("mediaResolution")]
public MediaResolution? MediaResolution { get; set; }
Property Value
ModelSelectionConfig
Optional. Config for model selection.
[JsonPropertyName("modelSelectionConfig")]
public ModelSelectionConfig? ModelSelectionConfig { get; set; }
Property Value
PresencePenalty
Optional. Presence penalty applied to the next token's logprobs if the token has already been seen in the response. This penalty is binary on/off and not dependant on the number of times the token is used (after the first). Use FrequencyPenalty for a penalty that increases with each use. A positive penalty will discourage the use of tokens that have already been used in the response, increasing the vocabulary. A negative penalty will encourage the use of tokens that have already been used in the response, decreasing the vocabulary.
[JsonPropertyName("presencePenalty")]
public double? PresencePenalty { get; set; }
Property Value
ResponseFormat
Output format per response modality. Vertex AI only.
[JsonPropertyName("responseFormat")]
public List<ResponseFormat>? ResponseFormat { get; set; }
Property Value
ResponseJsonSchema
Optional. Output schema of the generated response. This is an alternative to responseSchema that accepts JSON Schema. If set, responseSchema must be omitted, but responseMimeType is required.
[JsonPropertyName("responseJsonSchema")]
public JsonNode? ResponseJsonSchema { get; set; }
Property Value
ResponseLogprobs
Optional. If true, export the logprobs results in response.
[JsonPropertyName("responseLogprobs")]
public bool? ResponseLogprobs { get; set; }
Property Value
- bool?
ResponseMimeType
Optional. MIME type of the generated candidate text. Supported MIME types are:
text/plain: (default) Text output.
application/json: JSON response in the response candidates.
text/x.enum: ENUM as a string response in the response candidates.
Refer to the docs
for a list of all supported text MIME types.
[JsonPropertyName("responseMimeType")]
public string? ResponseMimeType { get; set; }
Property Value
ResponseModalities
Optional. The requested modalities of the response. Represents the set of modalities that the model can return, and should be expected in the response. This is an exact match to the modalities of the response. A model may have multiple combinations of supported modalities. If the requested modalities do not match any of the supported combinations, an error will be returned. An empty list is equivalent to requesting only text.
[JsonPropertyName("responseModalities")]
public List<Modality>? ResponseModalities { get; set; }
Property Value
ResponseSchema
Optional. Output schema of the generated candidate text. Schemas must be a subset of the
OpenAPI schema and can be
objects, primitives or arrays.
If set, a compatible ResponseMimeType must also be set. Compatible MIME types:
application/json: Schema for JSON response. Refer to the
JSON text generation guide
for more details.
[JsonPropertyName("responseSchema")]
public Schema? ResponseSchema { get; set; }
Property Value
RoutingConfig
Optional. Routing configuration.
[JsonPropertyName("routingConfig")]
public RoutingConfig? RoutingConfig { get; set; }
Property Value
Seed
Optional. Seed used in decoding. If not set, the request uses a randomly generated seed.
[JsonPropertyName("seed")]
public int? Seed { get; set; }
Property Value
- int?
SpeechConfig
Optional. The speech generation config.
[JsonPropertyName("speechConfig")]
public SpeechConfig? SpeechConfig { get; set; }
Property Value
StopSequences
Optional. The set of character sequences (up to 5) that will stop output generation.
If specified, the API will stop at the first appearance of a stop_sequence.
The stop sequence will not be included as part of the response.
[JsonPropertyName("stopSequences")]
public List<string>? StopSequences { get; set; }
Property Value
Temperature
Optional. Controls the randomness of the output.
Note: The default value varies by model, see the Model.Temperature attribute
of the Model returned from the getModel function.
Values can range from.
[JsonPropertyName("temperature")]
public double? Temperature { get; set; }
Property Value
Remarks
Deprecated by Google for Gemini 3.6 and later models (July 2026), along with TopP and TopK; leave unset for those models. See https://ai.google.dev/gemini-api/docs/whats-new-gemini-3.6#sampling-parameter-deprecation.
ThinkingConfig
Optional. Config for thinking features. An error will be returned if this field is set for models that don't support thinking.
[JsonPropertyName("thinkingConfig")]
public ThinkingConfig? ThinkingConfig { get; set; }
Property Value
TopK
Optional. The maximum number of tokens to consider when sampling. Gemini models use Top-p (nucleus) sampling or a combination of Top-k and nucleus sampling. Top-k sampling considers the set of TopK most probable tokens. Models running with nucleus sampling don't allow TopK setting. Note: The default value varies by Model and is specified by the TopP attribute returned from the model information. An empty TopK attribute indicates that the model doesn't apply top-k sampling and doesn't allow setting TopK on requests.
[JsonPropertyName("topK")]
public int? TopK { get; set; }
Property Value
- int?
Remarks
Deprecated by Google for Gemini 3.6 and later models; see Temperature.
TopP
Optional. The maximum cumulative probability of tokens to consider when sampling. The model uses combined Top-k and Top-p (nucleus) sampling. Tokens are sorted based on their assigned probabilities so that only the most likely tokens are considered. Top-k sampling directly limits the maximum number of tokens to consider, while Nucleus sampling limits the number of tokens based on the cumulative probability. Note: The default value varies by Model and is specified by the TopP attribute returned from the model information. An empty TopK attribute indicates that the model doesn't apply top-k sampling and doesn't allow setting TopK on requests.
[JsonPropertyName("topP")]
public double? TopP { get; set; }
Property Value
Remarks
Deprecated by Google for Gemini 3.6 and later models; see Temperature.
TranslationConfig
Real-time speech translation settings (Live API).
[JsonPropertyName("translationConfig")]
public TranslationConfig? TranslationConfig { get; set; }