Skip to content

AI 0.21.0: Image editing with named operations and vision calls

AI 0.21.0 adds image editing and image understanding. An app can edit a photo with named operations such as replacing the background or removing glare, describe or compare images, and try it all in the Playground.

Image editing

process_image/4 edits an image with named operations: background treatments, removing glare and reflections, relighting, recolouring one element, upscaling, restyling and more. They are combined into one prompt. A site can add its own operations through config or a saved prompt named image-op-<name>. Options are fitted to what the model accepts: an option it does not take is dropped with a warning, or refused with strict: true. dry_run: true returns the plan without making a request, and verify: adds a vision check of the result. edit_image/4 takes a free instruction instead.

Vision calls and providers

describe_image/3 answers in text or in JSON that matches a schema, and compare_images/4 compares images. Image calls work with OpenRouter, xAI and OpenAI, plus a default for OpenAI-compatible chat endpoints, and a host app can add its own provider adapters. Images are fetched through one checked downloader with a size limit that refuses internal addresses unless allowed. The usage log records image counts, sizes, operations and warnings, never the image bytes.

In the Playground

A new Image edit card takes one or more uploaded images: the first is edited, the rest are references. Pick Operations, write an instruction, or both, then choose Edit image or Describe. The option selects follow what the model accepts, and you can override the endpoint’s model and have the result checked against the original.

Other changes

generate_image/3 now goes through the endpoint’s provider adapter: OpenRouter endpoints post to /images instead of /images/generations, and the result carries the model and any warnings. The Endpoints list now sorts newest first by default.

Upgrading

No migration. Update the dependency.

Full release notes: AI 0.21.0

0.21.0 · 14 September 2026

Added

  • Provider-neutral image processing (PR #25). process_image/4 edits images with named operations (PhoenixKitAI.Images.Operations: background treatments, reflections, relight, recolour, upscale, restyle and more, extendable through :image_operations config or a saved image-op-<name> prompt) composed into one prompt. Options are fitted to the model’s published capabilities, dropped with a warning or refused under strict: true, and dry_run: true returns the plan without a request. verify: attaches a vision check of the result.
  • edit_image/4 for prompt-driven edits, describe_image/3 (free text or schema-parsed JSON) and compare_images/4 as vision verbs, plus image_models/2, image_model/1, image_options/1 and image_operations/0.
  • PhoenixKitAI.Provider behaviour with OpenRouter (unified /images), xAI (JSON /images/edits), OpenAI (multipart /images/edits, masks) and an OpenAI-compatible chat-completions default. Hosts add adapters through :provider_adapters.
  • PhoenixKitAI.Providers.HTTP: one bounded, host-checked image fetcher (resolved addresses, every redirect hop, :max_image_bytes, :allow_internal_image_urls). Output URLs always come back as bytes.
  • image_edit and vision request types, logged with image counts, byte sizes, operations and warnings, never the image bytes. Error payloads are kept only under the content-capture gate. A [:phoenix_kit_ai, :image, :request] telemetry event fires per call.
  • Playground image-edit card: upload, operations, model override, capability-driven option selects, Describe and verify.

Changed

  • generate_image/3 goes through the endpoint’s adapter: OpenRouter endpoints now post to /images instead of /images/generations. The result also carries :model and :warnings.
  • The Endpoints list defaults to newest first, matching what mount assigns.

Fixed

  • Chat-completions image edits no longer accept options they never send. On the OpenAI-compatible default adapter, and on OpenRouter with transport: :chat, only an aspect ratio reaches the provider. Yet process_image/4 fitted background, output_format, size and the rest as if they were sent, without a warning, and :remove_background kept its “fully transparent” wording. A new optional Provider.image_edit_options/2 callback declares what an edit sends: anything else is dropped with a {:dropped_option, …} warning, and the operation falls back to its white-background wording. Stored endpoint defaults the edit cannot send are left out without a warning.

AI 0.21.0. Install or update: {:phoenix_kit_ai, "~> 0.21"}, then mix deps.get && mix phoenix_kit.update. Full history: CHANGELOG.