PhoenixKitAI.Images.ImageModel (PhoenixKitAI v0.23.1)

Copy Markdown View Source

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.

Summary

Functions

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

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"}).

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

Whether the model lists option at all.

The values an enum option accepts, or [].

Types

constraint()

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

t()

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

Functions

allows?(arg1, option, value)

@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(entry)

@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(arg1)

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

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

supports?(arg1, option)

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

Whether the model lists option at all.

values(arg1, option)

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

The values an enum option accepts, or [].