Image Generation
Image generation runs through the ToothFairyAI backend. No API keys are required for the workspace-backed models; generation consumes UoI.
Models
| Id | Label | Character | Caps |
|---|---|---|---|
mystica_sd | Mystica SD | Fast, expressive | t2i, i2i |
mystica_realism_sd | Mystica Realism | Photoreal detail | t2i, i2i |
sorcerer_canvas | Sorcerer Canvas | Premium composition | t2i, i2i |
sorcerer_vision | Sorcerer Vision | High-fidelity renders | t2i, i2i |
mystica_vision | Mystica Vision | Highest image fidelity — default | t2i, 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.
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
- The agent (or you) calls the dispatcher with surface, model, prompt, and optional parameters.
- The daemon validates the request against the registry — unknown models, cross-surface combinations, and unavailable models fail fast with a
400. - The render runs asynchronously;
POST /media/generatereturns ataskIdimmediately. - Bytes are written into the project folder, named from the actual container (see below).
- The FileViewer renders it; the CLI or MCP returns metadata, never bytes.
Parameters
| Parameter | Values | Notes |
|---|---|---|
prompt | text | Required |
aspect | 1:1 16:9 9:16 4:3 3:4 | Model-dependent support |
output | filename | Auto-named when omitted |
image | project-relative path | Reference image (i2i) |
promptInfluence | 0–1 | How strictly to follow the prompt |
loop | boolean | GIF 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:
| Signature | Extension |
|---|---|
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
| Tool | Purpose |
|---|---|
list_media_models | Registered models per surface, aspects, duration caps, enabled audio kinds |
generate_media | Submit a render, returns { taskId } immediately |
wait_media | Long-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
| Endpoint | Method | Description |
|---|---|---|
/api/media/models | GET | Providers, models per surface, aspects, lengths, enabled audio kinds |
/api/media/config | GET / PUT | Provider configuration (secrets masked on read) |
/api/projects/:id/media/generate | POST | Submit a render → 202 { taskId } |
/api/projects/:id/media/tasks | GET | Tasks for a project |
/api/media/tasks/:id/wait | POST | Long-poll a task ({ since, timeoutMs }) |
Cross-origin requests are rejected: media generation is restricted to the local UI and the CLI.