ALLM.ImageResponse (allm v0.3.0)

Copy Markdown View Source

An image generation/edit/variation response. See spec §35.2.3.

Layer A — pure serializable data. Carries the resolved :images list, an :usage summary (%ALLM.ImageUsage{} — never nil), optional :id / :request_id / :model provider correlation fields, and an opaque :raw adapter-specific payload analogous to ALLM.Response.raw.

ETF round-trip via :erlang.term_to_binary/1 is total. JSON round-trip works whenever :raw is JSON-encodable; a non-encodable :raw raises Jason.EncodeError at encode time — the same caller-responsibility contract as ALLM.Response.raw.

Summary

Functions

Build an %ImageResponse{} from keyword opts.

Types

t()

@type t() :: %ALLM.ImageResponse{
  id: String.t() | nil,
  images: [ALLM.Image.t()],
  metadata: map(),
  model: String.t() | nil,
  raw: term(),
  request_id: String.t() | nil,
  usage: ALLM.ImageUsage.t()
}

Functions

new(opts \\ [])

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

Build an %ImageResponse{} from keyword opts.

Unknown keys raise KeyError via struct!/2.

Examples

iex> resp = ALLM.ImageResponse.new(model: "gpt-image-1")
iex> resp.images
[]
iex> resp.usage.images
0