Skip to main content

Image Generation

Image generation runs through the ToothFairyAI backend. No API keys are required for the workspace-backed models; generation consumes UoI.

Models​

IdLabelCharacterCaps
mystica_sdMystica SDFast, expressivet2i, i2i
mystica_realism_sdMystica RealismPhotoreal detailt2i, i2i
sorcerer_canvasSorcerer CanvasPremium compositiont2i, i2i
sorcerer_visionSorcerer VisionHigh-fidelity renderst2i, i2i
mystica_visionMystica VisionHighest image fidelity — defaultt2i, i2i

t2i = text-to-image, i2i = accepts a reference image.

Model hint strings are deliberately capability copy ("TF · photoreal detail"), never an upstream vendor name. The aliases exist so the implementation stays private; list_media_models returns exactly what the pickers use.

Availability flag

A model can be marked unavailable when its upstream deployment is broken. It is then rejected before dispatch, with the working alternatives named — rather than burning a submit and a poll before failing. All five current models are enabled.

How a request flows​

  1. The agent (or you) calls the dispatcher with surface, model, prompt, and optional parameters.
  2. The daemon validates the request against the registry — unknown models, cross-surface combinations, and unavailable models fail fast with a 400.
  3. The render runs asynchronously; POST /media/generate returns a taskId immediately.
  4. Bytes are written into the project folder, named from the actual container (see below).
  5. The FileViewer renders it; the CLI or MCP returns metadata, never bytes.

Parameters​

ParameterValuesNotes
prompttextRequired
aspect1:1 16:9 9:16 4:3 3:4Model-dependent support
outputfilenameAuto-named when omitted
imageproject-relative pathReference image (i2i)
promptInfluence0–1How strictly to follow the prompt
loopbooleanGIF output

There is no format picker and no width/height parameter. The backend does not accept them, so exposing them would be a lie.

File naming is truthful​

The backend labels every image as PNG, but some models emit JPEG and some WebP. Writing JPEG bytes to a .png name made the file mis-served as image/png.

The daemon now sniffs the magic bytes and names the file to match:

SignatureExtension
FF D8 FF.jpg
89 50 4E 47.png
RIFF…WEBP.webp

The MIME type follows the same detection. Prompts therefore instruct the agent to use the extension the tool returns, and thumbnail rendering accepts all three.

CLI​

"$OD_NODE_BIN" "$OD_BIN" media generate \
--project "$OD_PROJECT_ID" \
--surface image \
--model mystica_vision \
--aspect 16:9 \
--prompt "A ceramic coffee cup on warm paper, soft side light from the left"

The CLI picks up OD_DAEMON_URL and OD_PROJECT_ID from the environment the daemon injects at spawn. One line of JSON comes back:

{"file":{"name":"image-mystica-vision-….png","size":1843200,"kind":"image","mime":"image/png"}}

MCP​

ToolPurpose
list_media_modelsRegistered models per surface, aspects, duration caps, enabled audio kinds
generate_mediaSubmit a render, returns { taskId } immediately
wait_mediaLong-poll up to ~25s; status: "running" → call again with nextSince

Generation is async by design: renders take 1–15 minutes and the MCP client's default tool timeout is 30 seconds. Never sleep in a loop — drive wait_media.

Settings​

Default image model is configurable in Settings → Media Providers. The picker derives from the registry, so it cannot drift from what the dispatcher accepts. Selection is stored in the app config, not per project; per-project model choice lives in project metadata.

Using images in artifacts​

  • Reference — <img src="assets/hero.png"> (use the returned extension).
  • Background — background-image: url('…').
  • Download — the download chip on the file card.
  • Export — images are included in ZIP and mirrored exports.

Routes​

EndpointMethodDescription
/api/media/modelsGETProviders, models per surface, aspects, lengths, enabled audio kinds
/api/media/configGET / PUTProvider configuration (secrets masked on read)
/api/projects/:id/media/generatePOSTSubmit a render → 202 { taskId }
/api/projects/:id/media/tasksGETTasks for a project
/api/media/tasks/:id/waitPOSTLong-poll a task ({ since, timeoutMs })

Cross-origin requests are rejected: media generation is restricted to the local UI and the CLI.