llm.image/v1

A model makes pictures from a prompt, and from reference pictures it's given. They come back as files. Every call names its model as provider/model: a provider the app's admins added in Settings → LLM, a slash, and that provider's own id for the model. Shared types (File, Usage, ModelInfo, Job, the errors) are in pocketone.dev/ext/contracts/llm.

A wire contract at /api/_c/llm.image/v1 (image.go), one provider. The llm extension provides it, over Vultr, Cloudflare Workers AI, OpenRouter and any OpenAI-compatible API.

Use

In page code it's $llm.image (bound by the llm extension):

const r = await $llm.image.generateAsync({ model: "vultr/z-image-turbo", prompt: "a lighthouse at dusk, watercolor", aspectRatio: "16:9" })
record.set("cover", $llm.file(r.files[0]))

references are pictures the model draws from: one to change as the prompt says, or one whose style and characters a new scene keeps. Paint an anchor picture first, then every other picture with it as the reference, and a story's pictures share one look:

const anchor = (await $llm.image.generateAsync({ model, prompt: "a red fox in a blue scarf and a small owl in round glasses, watercolor" })).files[0]
const next = await $llm.image.generateAsync({ model, prompt: "Same style and characters as the reference. Show them rowing across a misty pond.", references: [anchor] })

Only a model whose listing has the feature "reference images" takes references (ModelInfo.Features, from models); offer them only then. Any other model answers not_supported, or the provider's own error.

Over HTTP (a superuser, or a token with the scope shown):

Operation HTTP Body Token scope
Generate POST /api/_c/llm.image/v1/generate {"model": "...", "prompt": "...", "n": 1, "size": "1024x1024", "references": [File]} llm
Models GET /api/_c/llm.image/v1/models ?provider= (optional) llm:read

Generate answers {"files": [File], "model", "usage"}. A File is {"name", "type", "data", "url"}: data is the bytes (base64), url the provider's own copy when it keeps one.

Errors: not_configured (no providers), unknown_model, not_supported, provider (the cloud's own error), timeout.

From Go: imagev1.Contract.Must(app) (from pocketone.dev/ext/contracts/llm/image/v1).

Provide

Implement imagev1.Image and provide it in Register (imagev1.Contract.Provide(app, impl)). Route on the provider/ prefix, answer not_supported for a provider that can't do this kind, unknown_model for a missing model or provider, and provider with the cloud's own message (never its key) when the cloud refuses. Fill model with the full provider/model that answered, and usage with what the provider reports.

List "reference images" (llm.FeatureReferenceImages) in a model's Features only when both the model and your provider take references; answer not_supported for references you can't send.

Decisions

  • References are a field of Generate, not an Edit operation (Ben, 2026-11-24). Drawing a new scene from a reference isn't editing it, and providers treat both the same way: Vultr answers a generation with images as an edit. The earlier Edit operation and EditInput are gone.
  • A feature says which models take them, not inputs containing "image": inputs is what the provider says the model reads, but whether references work also depends on the provider here (Cloudflare lists models that read images, and its driver sends none).

Commands and APIs

Every operation is a REST endpoint, a pocketone command and an MCP tool, all generated from the contract and behind the same token scope check and hooks. See Remote CLI, or the full CLI, Extension APIs and MCP references.

generate

Makes pictures from a prompt, and from the reference pictures it's given.

REST POST /api/_c/llm.image/v1/generate
CLI pocketone remote llm image generate --model <value> --prompt <value> --n <n> --size <value> --aspectratio <value> --references <json> --options <json>
MCP llm_image_generate
Token scope llm
Input field Flag Type
model --model string
prompt --prompt string
n --n int
size --size string
aspectRatio --aspectratio string
references --references json
options --options json

models

Lists the image models of every provider in Settings → LLM.

REST GET /api/_c/llm.image/v1/models
CLI pocketone remote llm image models --provider <value>
MCP llm_image_models
Token scope llm:read
Input field Flag Type
provider --provider string

Extensions

Extension
llm provides

License

MIT