# `Gemini.Types.Interactions.ImageConfig`
[🔗](https://github.com/nshkrdotcom/gemini_ex/blob/v0.15.0/lib/gemini/types/interactions/image_config.ex#L1)

Configuration for image generation in Interactions.

This type controls image generation parameters when using the Interactions API
with image generation capabilities.

## Aspect Ratios

The following aspect ratios are supported:

| Ratio | Description |
|-------|-------------|
| `"1:1"` | Square format |
| `"2:3"` | Portrait (vertical) |
| `"3:2"` | Landscape (horizontal) |
| `"3:4"` | Portrait (vertical) |
| `"4:3"` | Landscape (horizontal), standard photo |
| `"4:5"` | Portrait (vertical), Instagram-style |
| `"5:4"` | Landscape (horizontal) |
| `"9:16"` | Portrait (vertical), phone screen/stories |
| `"16:9"` | Landscape (horizontal), widescreen |
| `"21:9"` | Ultrawide panoramic |

## Image Sizes

The following image sizes are supported:

| Size | Description |
|------|-------------|
| `"1K"` | ~1024 pixels on the longest edge |
| `"2K"` | ~2048 pixels on the longest edge |
| `"4K"` | ~4096 pixels on the longest edge |

## Example

    config = %Gemini.Types.Interactions.ImageConfig{
      aspect_ratio: "16:9",
      image_size: "2K"
    }

    # Use in Interactions generation config
    Gemini.APIs.Interactions.create(
      session_id: session_id,
      input: "Generate an image of a sunset",
      config: %{
        generation_config: %{
          image_config: config
        }
      }
    )

# `t`

```elixir
@type t() :: %Gemini.Types.Interactions.ImageConfig{
  aspect_ratio: String.t() | nil,
  image_size: String.t() | nil
}
```

Image generation configuration.

- `aspect_ratio` - The aspect ratio for generated images
- `image_size` - The size/resolution for generated images

# `from_api`

```elixir
@spec from_api(map() | nil) :: t() | nil
```

Creates an ImageConfig from API response.

# `new`

```elixir
@spec new(keyword()) :: t()
```

Creates a new ImageConfig with validation.

Raises `ArgumentError` if invalid values are provided.

## Parameters

- `opts` - Keyword list with configuration:
  - `:aspect_ratio` - One of ["1:1", "2:3", "3:2", "3:4", "4:3", "4:5", "5:4", "9:16", "16:9", "21:9"]
  - `:image_size` - One of ["1K", "2K", "4K"]

## Examples

    ImageConfig.new(aspect_ratio: "16:9", image_size: "2K")
    #=> %ImageConfig{aspect_ratio: "16:9", image_size: "2K"}

    ImageConfig.new(aspect_ratio: "4:5")
    #=> %ImageConfig{aspect_ratio: "4:5", image_size: nil}

    ImageConfig.new(aspect_ratio: "invalid")
    #=> ** (ArgumentError) Invalid aspect_ratio: invalid

# `to_api`

```elixir
@spec to_api(t() | nil) :: map() | nil
```

Converts ImageConfig to API format with snake_case keys.

# `valid_aspect_ratio?`

```elixir
@spec valid_aspect_ratio?(String.t()) :: boolean()
```

Checks if an aspect ratio is valid.

# `valid_aspect_ratios`

```elixir
@spec valid_aspect_ratios() :: [String.t()]
```

Returns the list of valid aspect ratios.

# `valid_image_size?`

```elixir
@spec valid_image_size?(String.t()) :: boolean()
```

Checks if an image size is valid.

# `valid_image_sizes`

```elixir
@spec valid_image_sizes() :: [String.t()]
```

Returns the list of valid image sizes.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
