# `PhoenixKitAI.Images.ImageModel`
[🔗](https://github.com/BeamLabEU/phoenix_kit_ai/blob/0.23.1/lib/phoenix_kit_ai/images/image_model.ex#L1)

What one image model accepts, in provider-neutral terms.

Built from a provider's capability listing (OpenRouter publishes one at
`/images/models`; other providers get a static list from their adapter)
and used by `PhoenixKitAI.Images` to keep a request inside what the
model can do: an option the model does not list is dropped with a
warning, or refused when the caller asked for `strict: true`.

`params` maps an option name to its constraint:

  * `{:enum, values}` — one of `values` (strings)
  * `{:range, min, max}` — an integer within the range
  * `:boolean` — accepted, any value
  * `:any` — accepted, unconstrained

The option names are the ones `PhoenixKitAI.Images` uses everywhere:
`:aspect_ratio`, `:resolution`, `:size`, `:quality`, `:background`,
`:output_format`, `:output_compression`, `:n`, `:seed`,
`:input_references`.

# `constraint`

```elixir
@type constraint() ::
  {:enum, [String.t()]} | {:range, integer(), integer()} | :boolean | :any
```

# `t`

```elixir
@type t() :: %PhoenixKitAI.Images.ImageModel{
  description: String.t() | nil,
  id: String.t(),
  name: String.t() | nil,
  params: %{optional(atom()) =&gt; constraint()},
  pricing: map(),
  provider: String.t() | nil,
  raw: map()
}
```

# `allows?`

```elixir
@spec allows?(t() | nil, atom(), term()) :: boolean()
```

Whether `value` is acceptable for `option` on this model. Unknown
options are not; values are compared as strings for enums.

# `from_openrouter`

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

Builds a model from one entry of OpenRouter's `/api/v1/images/models`
listing. `supported_parameters` there is typed per field
(`%{"type" => "enum", "values" => [...]}` /
`%{"type" => "range", "min" => m, "max" => n}` /
`%{"type" => "boolean"}`).

# `max_references`

```elixir
@spec max_references(t() | nil) :: non_neg_integer() | nil
```

How many reference images the model takes for an edit (nil = unknown).

# `supports?`

```elixir
@spec supports?(t() | nil, atom()) :: boolean()
```

Whether the model lists `option` at all.

# `values`

```elixir
@spec values(t() | nil, atom()) :: [String.t()]
```

The values an enum option accepts, or `[]`.

---

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