Table of Contents

Class ImageConfig

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

The image generation configuration to be used in GenerateContentConfig.

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

Properties

AspectRatio

Aspect ratio of the generated images. Supported values are "1:1", "2:3", "3:2", "3:4", "4:3", "9:16", "16:9", and "21:9".

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

Property Value

string

ImageOutputOptions

Optional. The image output format for generated images. This field is not supported in Gemini API.

[JsonPropertyName("imageOutputOptions")]
[JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingNull)]
public ImageConfigImageOutputOptions? ImageOutputOptions { get; set; }

Property Value

ImageConfigImageOutputOptions

ImageSize

Optional. Specifies the size of generated images. Supported values are 1K, 2K, 4K. If not specified, the model will use default value 1K.

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

Property Value

string

OutputCompressionQuality

Compression quality of the generated image (for image/jpeg only). This field is not supported in Gemini API.

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

Property Value

int?

OutputMimeType

MIME type of the generated image. This field is not supported in Gemini API.

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

Property Value

string

PersonGeneration

Controls the generation of people. Supported values are: ALLOW_ALL, ALLOW_ADULT, ALLOW_NONE.

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

Property Value

string

ProminentPeople

Optional. Controls whether prominent people (celebrities) generation is allowed. If used with personGeneration, personGeneration enum would take precedence. For instance, if ALLOW_NONE is set, all person generation would be blocked. If this field is unspecified, the default behavior is to allow prominent people. This field is not supported in Gemini API.

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

Property Value

ProminentPeople?

Methods

FromJson(string, JsonSerializerOptions?)

Deserializes a JSON string to a ImageConfig object.

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

Parameters

jsonString string

The JSON string to deserialize.

options JsonSerializerOptions

Optional JsonSerializerOptions.

Returns

ImageConfig

The deserialized ImageConfig object, or null if deserialization fails.