Generate Images into a Canvas
Every image an agent makes in Gavana lands as an image node on a canvas you name: a new image, an edited copy of an existing one, or variations. The tool creates the empty target nodes, queues the provider, and returns straight away. The finished picture is written into those nodes when the run ends.
If the change is a resize, crop, reframe, or colour grade, an Image Action does it without AI credits.
Image work charges the AI provider connected to the account, once per output. A direct request in the user’s current message (“make three versions of this”) approves that one job. A repeated request does not approve new spend, and a failure is never retried automatically. Give each intended job one caller-stable idempotencyKey, and reuse it only to repeat the identical request.
Scopes. Hosted generate_image_in_canvas and edit_image_in_canvas: canvas:read, canvas:write, asset:read, image:generate, job:manage, plus element:read when you pass elements. get_image_run and list_image_runs: job:manage. model_list: image:generate. canvas_validate: canvas:read. The CLI and the local MCP server call the API with your saved token: a start needs canvas:read, canvas:write, asset:read, and image:generate (plus element:read for Elements), and waiting for or reading a run needs job:manage. A CLI --preflight needs only canvas:read and asset:read.
What each surface can do
| Need | Hosted MCP | Local MCP | CLI |
|---|---|---|---|
| Different images in one call | items (1–4) | No — one image_generate call per image | No — one command per image |
| One prompt, several outputs | count (1–4) | count (1–4) | --count (1–4) |
| Aspect ratio as a parameter | requirements.aspectRatio, or aspectRatio per item | requirements.aspectRatio | No ratio flag — pass --size |
| Edit an existing image | operation: "edit" | image_edit | gavana image edit |
| Variations of an existing image | No variations operation | image_variations | gavana image variations |
| A local file as a reference | Save it first | asset_upload first | --reference ./file.png uploads it |
| Wait for the result | wait (up to 50 s), then get_image_run | wait, or run_wait | --wait, or gavana run wait |
edit_image_in_canvas still answers by name but is not in the default hosted listing; generate_image_in_canvas with operation: "edit" makes the same request.
Call sequence
hosted: model_list → [approval] → generate_image_in_canvas → get_image_run (until terminal) → canvas_validate → report handles
local: model_list → model_get → [approval] → image_generate | image_edit | image_variations → run_wait → canvas_validate
CLI: model list → model get → [approval] → image generate | edit | variations --wait → report handlesSteps
Hold one task canvas
Every call names an exact canvas as destination. If the task has none, create one once — canvas_create over MCP, gavana canvas create --title "…" --idempotency-key KEY on the CLI — and reuse that handle for imports, references, and every generation. There is no shared default canvas.
Pick a model
{ "name": "model_list", "arguments": { "capability": "image.generate" } }gavana model list --capability image.generate --jq '.models[].handle' -r
gavana model get model:OPAQUE_MODEL_KEY --prettyAsk for image.edit when you will pass references or edit, and image.variations for variations. Omitting model uses Gavana’s configured default. If the user named a model and it is not in the list, say so; never substitute another.
Check. Read the model’s parameters: the count maximum (some models make one image per job), the references maximum, and what size accepts — an aspect ratio for some models, pixel dimensions or a resolution tier for others. estimatedSeconds tells the user roughly how long to wait.
Gather references, and optionally Elements
References are images already in Gavana, passed by handle: a node: handle from canvas_get, or an asset: handle. Save an image the user supplied before you reference it — see Save an image — and look at it with get_canvas_image before you rely on it. An image count is not visual inspection.
Give a reference a role when it matters, such as { "handle": "node:PRODUCT_NODE", "role": "identity" }. The roles are source, identity, construction, texture, fit, and style. A job takes at most 16 images, shared between references, source, and the source images of any Elements.
To apply saved visual rules, pass up to eight version-pinned Elements as elements: ["element:ELEMENT_ID@v3"], or repeat --element on the CLI. Find them with element_list and element_get; Reuse Elements covers the application modes.
Optionally preflight, for free
A preflight compiles the reference plan and the settings a run would use, without creating nodes or spending anything. Hosted: preflight: true with an existing destination and a targetNodeId (an empty image node), or with items. Local: preflight: true with explicit targetNodeIds. CLI: --preflight with explicit --target node:… handles and only node: or asset: references.
Check. Show the user any parameterAdjustments and warnings. A size the model cannot honour is replaced, and the plan says with what.
Get explicit approval
Unless the user’s current message already asked for exactly this, state the model, how many images, their ratios, and the canvas, and say it uses their connected provider. Then wait for a yes. Choose the idempotency key now, once.
Start the generation
Different images — hosted items. One item per output, each with its own prompt and optional aspectRatio and label. References, Elements, model, and destination apply to every item, and each item runs as its own one-image job. With items, omit prompt, promptNodeId, count, targetNodeId, and requestContract.
{
"name": "generate_image_in_canvas",
"arguments": {
"destination": "canvas:OWNER_UID:CANVAS_ID",
"idempotencyKey": "bottle-hooks-2026-10-05-a",
"model": "model:OPAQUE_MODEL_KEY",
"references": [{ "handle": "node:PRODUCT_NODE", "role": "identity" }],
"requirements": { "aspectRatio": "9:16" },
"originalWording": "Three hooks for the bottle: gym, desk, trail. All 9:16 stories.",
"items": [
{ "prompt": "The bottle on a gym bench beside a towel, hard morning light", "label": "Gym" },
{ "prompt": "The bottle on a tidy desk next to a laptop, soft window light", "label": "Desk" },
{ "prompt": "The bottle clipped to a backpack on a mountain trail at dusk", "label": "Trail" }
]
}
}Every node: reference is read back and every item is dry-run before anything is written or charged, so one bad item costs nothing.
One prompt, several outputs — count. count: 3 copies one prompt to three separate outputs. It is for variations of one idea, never for different scenes.
The aspect ratio is a parameter. Pass the ratio the user stated as requirements.aspectRatio, or per item as aspectRatio. A ratio written only into the prompt leaves the output in the model’s default shape, and a call with items whose prompts or originalWording state a ratio the items do not pass is refused.
Local MCP has no items: call image_generate once per distinct image, each with its own key.
{
"name": "image_generate",
"arguments": {
"destination": "canvas:OWNER_UID:CANVAS_ID",
"idempotencyKey": "bottle-desk-2026-10-05-a",
"prompt": "The bottle on a tidy desk next to a laptop, soft window light",
"references": [{ "handle": "node:PRODUCT_NODE", "role": "identity" }],
"requirements": { "aspectRatio": "4:5" },
"count": 2
}
}The CLI has no items and no ratio flag, and its --json input rejects items and requirements. Pass a --size the model’s size parameter accepts, then confirm settings.effectiveSize in the result.
gavana image generate \
--destination "$TASK_CANVAS" \
--model model:OPAQUE_MODEL_KEY \
--prompt "The bottle on a tidy desk next to a laptop, soft window light" \
--reference node:PRODUCT_NODE --reference-role identity \
--size SIZE_FROM_MODEL_GET \
--count 2 \
--idempotency-key bottle-desk-2026-10-05-aA --reference may also be a local PNG, JPEG, WebP, or GIF of at most 50 MB, - for stdin, or clipboard; it is uploaded privately first. Without --idempotency-key the CLI makes a random key, which cannot protect a retry.
Edit an existing image
An edit makes a new output and leaves the source untouched. Pass the image being edited as source; references are extra guidance, not the image being edited.
{
"name": "generate_image_in_canvas",
"arguments": {
"operation": "edit",
"destination": "canvas:OWNER_UID:CANVAS_ID",
"source": "node:HERO_NODE",
"prompt": "Warm the light to late afternoon; keep the bottle identical",
"preserve": ["The bottle's shape, label, and colour"],
"idempotencyKey": "hero-warm-2026-10-05-a"
}
}changeRegions — up to eight normalized { x, y, width, height } rectangles — limits the change to those areas and keeps the source’s pixels everywhere else. Some models need an explicit size matching the source’s aspect ratio for that; Gavana refuses rather than guess. Locally the same request is image_edit. On the CLI:
gavana image edit --destination "$TASK_CANVAS" --source node:HERO_NODE \
--prompt "Warm the light to late afternoon; keep the bottle identical" \
--change-region 0,0,1,0.4 --idempotency-key hero-warm-2026-10-05-aMake variations
Variations start from an existing image, passed as a reference or as source:
gavana image variations --destination "$TASK_CANVAS" --reference node:HERO_NODE \
--prompt "The same bottle from new camera angles" \
--count 3 --idempotency-key hero-variations-2026-10-05-aLocally it is image_variations. The hosted server has no variations operation: use count to vary one prompt, or an edit when the new image must stay close to an existing one.
Watch it finish
A start returns queued progress with the run: handle and the targetNodeIds where the images will land. Report that it is queued, then follow nextAction: it names the tool to call next, even one that is not in your listing.
- Hosted:
get_image_runwith{ "runId": "run:RUN_ID" }until the status is terminal. It reconciles state, so it is not read-only;includeImage: trueinlines the picture. A start withwait: trueblocks for at mostwaitSeconds(1–50), andwaitTimedOut: truemeans the job is still running. - Local:
run_waitwith{ "runId": "run:RUN_ID", "timeoutSeconds": 900 }, orwait: trueon the start.job_waittakes the olderjob:alias of the same run. - CLI: add
--wait --progressto the start (15-minute default; change it with--timeout), or rungavana run wait run:RUN_ID --progresslater.
Lost the handle? list_image_runs — locally run_list, on the CLI gavana api GET /runs --field status=all — lists runs newest first, with their canvas. Find the existing run before you ever consider starting another. Watch, wait for and cancel a run covers waiting and cancelling in depth.
Check. A call with items returns one run per item in runs. If it stopped early, an uncertain item may already be running and charged: repeat the same call with the same key to observe it, and never resubmit it under a new key.
Verify and report
The terminal run carries images, each with a durable nodeId and assetId, plus canvasUrl, settings, and doneClaimAllowed. Over MCP, call canvas_validate with the canvasId and the new handles as nodeIds, and claim done only when completionReview.doneClaimAllowed is true. On the CLI, read the new node back with gavana canvas get "$TASK_CANVAS" --node node:NEW_NODE.
Report the node: and asset: handles and the canvas link. previewUrl is a scoped review link, not the record. The run: record expires — 15 minutes after Gavana first finalizes a successful result, 24 hours before that — so never hand it over as the result.
What you end up with
- One image node per output on the task canvas, each with a durable
node:andasset:handle - The settings actually used, including any size Gavana had to adjust
- On failure, a terminal
failure.codewithfailure.retryable, and a decision to hand back to the user
When it fails
| Symptom | Cause | Fix |
|---|---|---|
insufficient_scope (hosted) | The connection lacks a scope the tool needs | Reconnect with full access |
| “Describe one complete image only.” | One prompt asks for several images | items for different images, count for repeats |
| “items[n] asks for 9:16 but passes no aspect ratio…” | A stated ratio was not passed | Set the item’s aspectRatio or requirements.aspectRatio |
| “items[n] repeats items[m].” | Two identical items | Use count |
| “Do not put URLs in image prompt prose.” | A URL in the prompt | Save the image or page with save_image_to_canvas and pass its node: handle |
| “An edit requires an explicit source reference.” | operation: "edit" with no source | Pass source |
product_variant_mixed | References from one product page mix variants | Pass one variant’s references. Nothing was started |
| “Model … cannot use image references.” | A generation-only model was given references | Pick a model with image.edit. Gavana never drops references |
| “Model … cannot preserve required aspect ratio …” | The model cannot make that shape at that size | Choose another model, or ask before changing the ratio |
409 conflict “This idempotency key was already used for a different image or Action request.” | Same key, different request | A different request is new work: approval, then a new key |
409 conflict “The canvas changed after it was read.” | The canvas changed while the job was being prepared | If details.paidJobNotSubmitted is true, nothing was queued; repeat the identical call with the same key |
429 rate_limited “This account already has N active image or Action jobs…” | The account’s concurrent-job limit | details.activeRuns names the runs holding it; wait for one to finish |
402 payment_required | No image-generation access, or the saved provider key is out of credit, rate limited, or rejected | Report the message to the user; there is nothing to retry |
invalid_image_input (local) | For example “edit requires source or references.” | Fix the input; nothing was sent |
“Unknown image option: —aspect-ratio.” (CLI exit 2) | Image commands have no ratio flag | Use --size |
Terminal failed with provider_rejected, provider_timeout, canvas_target_deleted, … (CLI exit 9 after --wait) | The provider or canvas delivery failed | Report it and stop. A new attempt is new spend: ask, then use a new key |
Related
- The safety contract
- Save an image and Reuse Elements
- Run an Image Action and Watch, wait for and cancel a run
- Generate video
- MCP tools guide and CLI reference
- Generate and observe an image with the raw API
- Images, Runs, and Models