Image generation
Myra AI Workspace can generate an image from a text description and edit an image the user uploaded. Both are exposed to the model as a single generate_image tool: when a user asks the assistant to create, draw, or illustrate something — or to change, recolor, or restyle an image they just attached — the model calls the tool, the gateway renders the image with a self-hosted, EU-hosted model, and the result is shown inline in the chat.
- Text-to-image: a prompt produces a new image.
- Image-to-image (editing): an uploaded image plus a prompt produces an edited image (for example "make the car red", "turn this into a watercolor"). The edited image keeps the source image's aspect ratio and is at most about 1 megapixel.
Both directions run entirely on EU-hosted infrastructure (no third-party image provider) — including the uploaded source image, which is sent only to the same EU-hosted model as text prompts — satisfying EU data-residency requirements.
How it works
- The gateway advertises a
generate_imagetool to the model when the gateway has image generation enabled and the client signals support with thex-aig-image-genrequest header (the web chat always sends it; accepted values and the rejection rules are in the inference API reference). With image generation disabled on the gateway the tool is withheld from the model regardless of the header, so the model cannot call it. - When the model calls
generate_imagewith aprompt(and an optionalsize), the gateway sends the prompt to the EU-hosted image model and receives a PNG. When the model setsedit_uploaded_image: true, the gateway instead takes the image the user attached to their latest message, prepares it for the edit (see the source-image rules below), sends it together with the prompt to the model's edit endpoint, and receives the edited PNG. "Latest message" is the message the user sent for this turn: the assistant may run other tools first, and the gateway's own continuation steps within the turn never replace it as the source. When the user regenerates an answer with a reason, the source is the message that answer replied to (not the reason). - The image is stored and linked to the assistant message that produced it; the tool returns only a short status string to the model (the raw image is never placed in the model context).
- The client renders the image inline in the assistant's reply and offers a full-resolution view.
Image-to-image (editing) works on the image attached to the message that asks for the edit. The model decides to edit from the user's request — it does not need to see the image. A non-vision model receives the attached image as a text description and is told the system still holds the original, so it can call generate_image with edit_uploaded_image: true; the gateway then forwards the original attached image (not the description) to the EU-hosted image model for the edit. (This applies to API clients that send the image itself. The web chat sends an image uploaded while a model without image input is selected only as its text description, so such an image cannot be edited there — select a model with image input before attaching it.)
Editing an image from earlier in the chat ("Use this image?")
Users often upload a picture first and ask for the change in a later message ("now make it brighter"). The assistant never edits an older image on its own guess. Instead, when the message that asks for the edit has no image attached:
- The gateway looks up the most recent image of the conversation — an image you uploaded, or one the assistant produced (generated images, charts, cut-outs). On a gateway that masks personal data an uploaded photo is kept as its file (the model only reads the picture's text); it is offered and previewed all the same. One difference: there the stored file is the original you uploaded (without masking, a photo sent to a model that reads images is kept as a copy reduced to about 7.4 MB), so a photo larger than the tool's limit (12 MB for an edit, 10 MB for animating or removing the background) is shown as unusable — attach a smaller copy.
- It shows that image under the reply with three buttons: Use this image, Pick another (a list of this chat's images that can be edited), and Attach new (your device's file picker). Nothing is edited yet; the assistant only asks you to confirm.
- Use this image (or a picture chosen under Pick another) sends a short confirmation ("Yes, edit this image.") that names exactly that image. The assistant then edits that image — the choice is yours, never the model's. Regenerate of that answer and Send again keep your choice; editing the confirmation message cancels it (the image is offered again).
Behaviour in the unhappy cases:
- No image anywhere in the chat, a private chat (nothing is stored to look up), or a conversation you do not own (for example a shared conversation you co-drive): the assistant asks you to attach an image, as before.
- The most recent image cannot be edited (a GIF, for example — PNG, JPEG and WebP can be edited; at most 12 MB): it is still shown with the reason, Use this image is disabled, and Pick another / Attach new stay available. A GIF is not converted.
- The image was deleted (or the answer it belonged to was replaced by a regenerate) before you confirm: the card says it is no longer available and Use this image is disabled. If it disappears in the moment between your click and the send (for example deleted in another tab), the message is not sent and the chat shows "This image is no longer available in this chat."; nothing is put into your message box.
- The preview cannot be loaded (a network problem): the card says so and Use this image stays disabled — you only confirm an image you can see; Pick another and Attach new stay available.
- An image the assistant made earlier in the same reply (for example "draw a cat and then remove its background" in one message) can be used from your next message; the assistant tells you to ask again.
- Typing "yes" instead of pressing the button selects nothing — the assistant shows the card again. After a page reload the card is not shown again until the assistant is asked again.
- Local-only (Tier-1) projects never offer the card: image tools are not available there.
- The same confirmation works for Animate (video from an image) and Remove background.
The card and the confirmation rules are listed in the inference API reference.
Several images in one message
An edit works on one image. Combining several photos — putting a face, pose, outfit or object from one picture into another, or merging two pictures — is not supported. When the message that asks for the edit carries two or more images:
- Nothing is edited and no image is picked. The assistant says that it can only use one image as the base and asks which one you want.
- To continue, attach that one image again, on its own, together with the change. Naming it ("the first one") is not enough: the gateway does not pick one image out of a message that has several, and such a message is not offered on the Use this image? card either (the assistant asks you to attach the image).
- Pictures inside an attached document (a PDF or Word file read as text) are not edit sources in a saved chat — a photo plus a document with a logo edits the photo. In a private chat they are sent like photos and count as images. To edit one of a document's pictures, save it as an image file and attach that file on its own.
- A brand-new picture or video is still made in a message with attachments — for example "make a cover picture for this report". The assistant is told that it was made from your text only and does not use your images or files, so it does not present it as made from them.
- An image you confirmed with Use this image is edited even when the confirmation message also carries attachments — your explicit choice wins.
- The same rule applies to Animate (video from an attached image) and Remove background.
- The assistant is told in advance. In the web chat, when your latest message carries two or more images and an image tool (edit, animate or remove background) is on, the assistant's instructions for that turn state the count up front. When you ask it to edit, animate or cut out one of them, combine them, or carry something from one onto another, it says at once that it can use only one image as the base and asks you to attach that one, instead of announcing that it will "use the first one" and then doing nothing. For anything else it does not mention the limit. The notice limits only the image tools that work on those images: questions about the images (a damage list of two photos, say), and a new picture or clip made from a text description alone (for example a brand-new cover picture), work as usual. This advance notice exists in the web chat only; callers of the API get the tool's refusal alone (the same answer, given when the tool is called).
- Requests the assistant declines for a single image (for example sexualised edits of a real person) are declined as before.
Which copy of your image is edited
In a saved chat the gateway reads the image from your stored message, not from what your browser sent with the request: the inline copy the assistant was given, or — on a gateway that masks personal data, or with a model without image input, where the message keeps only a text description — the file you uploaded. So editing an attached photo works the same on every gateway, also after Regenerate, Send again or editing your message. A live co-driver's edit uses the image the message shows (its inline copy); where the message keeps only a text description, its uploaded file is the conversation owner's to use (as file downloads are), so the co-driver is told the owner can make that edit. If the picture's file never reached the chat (its upload failed, was refused or was too large), the assistant asks you to attach it again — it never edits an older image instead. In a private chat (nothing is stored) the image comes from the request. The exact rules are in the inference API reference.
Enabling it
Gateways created via self-service signup enable image generation by default (using flux.2-dev, the self-hosted EU model), so a fresh self-serve gateway is ready to generate images with no extra setup. You can turn it off — or change the image model — per gateway from the admin UI: Gateways → select the gateway → Edit → Search & tools → Image Generation → untick/tick Enable image generation (change the model only if a different image model is deployed) → Save Changes. The gateway overview shows an Image Gen status card reading on or off. Config changes are picked up within about a minute (gateway configuration is cached briefly).
Once enabled, the /easy chat surface supports it automatically — no client changes are required. The model decides when to call the tool based on the user's request (ask it to create, draw, or generate an image); it is not invoked for ordinary questions. Only a tool-capable model on the gateway will invoke it — a model that does not support tool calls will describe the image in words instead of generating one.
Image generation is not available to scheduled or automated agent runs.
Tool contract
The model-facing tool accepts:
| Field | Type | Required | Notes |
|---|---|---|---|
prompt |
string | yes | For a new image: the description. For an edit: the change to apply. Up to 4000 bytes (longer is rejected). Non-ASCII text such as umlauts, accents or emoji takes 2 to 4 bytes per character, so a prompt in such a language reaches the limit with fewer than 4000 characters. Must be non-empty. An edit with an empty prompt is rejected (no image is produced) — it usually means the request was a question about the image, not an edit; the model is told to answer in text or state the specific change. |
size |
string | no | Output size for a new image: one of 256x256, 512x512, 1024x1024 (default), 1024x1792, 1792x1024. Any other value falls back to the default. Ignored when editing (the edit follows the source image's aspect ratio, at most about 1 megapixel). |
seed |
integer | no | A whole number from 0 to 4294967295 that makes the image reproducible (see Reproducible images below). Also accepted as a string of digits. Applies to a new image and to an edit. Absent (or null): the gateway picks a random seed. Present but not such a number (negative, fractional, too large, text, true, …): the call is rejected with "'seed' must be a whole number from 0 to 4294967295 — omit 'seed' for a new random image" and nothing is generated — a malformed seed is never replaced by a random one. |
num_inference_steps |
integer | no | How many refinement steps the image model takes, a whole number from 1 to 50. More steps usually mean more detail and a longer wait. Applies to a new image and to an edit. Absent (or null): the image service's default. Present but not such a number (0, 51, 1.5, text, true, …): the call is rejected and nothing is generated — it is never rounded or replaced by the default. |
guidance_scale |
number | no | How closely the image follows the description, from 0 to 20 with at most three decimals (for example 5.5). Applies to a new image and to an edit. Absent (or null): the image service's default. Present but not such a number (negative, over 20, more than three decimals, text, true, …): the call is rejected and nothing is generated — it is never rounded or replaced by the default. |
edit_uploaded_image |
boolean | no | When true, edit the image attached to the user's latest message instead of generating a new one. Accepts the boolean true, the number 1, or the strings "true"/"1"; any other value (including false) means text-to-image. The latest message must carry exactly one image (see Several images in one message). |
Validation and limits (all enforced server-side):
- A request is rejected only when it has neither a saved conversation nor a live-delivery channel. A turn that can deliver live (as the chat UI always can) still receives the image even for an unsaved conversation — it is delivered but stored nowhere (see Data lifecycle below).
- At most 4 images per reply are shown (across generation, editing, background removal, video clips, code-interpreter charts, audio clips and connector media). When you ask for more — "make 6 cartoons" — the reply makes 4, says which ones are still missing, and makes them when you answer continue; it never claims the missing ones exist. (Pictures a connector or the code interpreter returned beyond the limit are reported as not shown; the assistant offers to try again on continue.) Once the image tools have reached the limit they are not offered again within that reply. Details: the per-reply media limit.
- Editing — several images. When the turn's message has two or more pictures — read from the stored message in a saved chat, from the request otherwise; malformed picture blocks count too (see the counting rules) — nothing is edited and the tool tells the model that only one image can be the base and that the user should attach that one image again on its own. A text-to-image call is never refused for attachments; its result tells the model it was made from the text only. When the latest message has no image and the newest image of the chat is a message with several images (or one whose upload never reached the chat), nothing is offered and the user is asked to attach the image again. An image confirmed with Use this image is checked first and is edited. The exact rules are in the inference API reference.
- Editing — the uploaded source image (untrusted, client-supplied) is read from the turn's ONE source — the stored message in a saved chat (its inline copy, else its uploaded file; see Which copy of your image is edited above), the request otherwise. From the request it is accepted only when it is present in the user's latest message as a base64
data:image URL, decodes successfully, is at most 12 MB, and is a PNG, JPEG or WebP (verified by the file's magic bytes, not the client-declared MIME type). Remote (http(s)) image URLs are ignored — the gateway never fetches them, and native Anthropicimageblocks (/v1/messages) are not used as an edit source. If the latest message has no image, the newest image of the conversation is offered for confirmation (see Editing an image from earlier in the chat above); without one, the tool tells the model to ask the user to attach one. A confirmed image is loaded by the gateway from the conversation (only an image of a live message of this conversation, only for its owner) and passes the same checks. - Every accepted source image is re-encoded by the gateway before the edit: decoded, turned upright according to its EXIF orientation, scaled down so its longest side is at most 1448 pixels (the image model accepts at most about 2 megapixels per source image — a typical 12-megapixel phone photo used to be rejected), and written as a JPEG (a JPEG source) or a PNG (a PNG or WebP source); transparent areas become white (the image model does not support transparency). The re-encoded image carries no metadata (EXIF, GPS), so none of it reaches the image model. An image the gateway cannot decode (corrupt or truncated) is rejected before anything is sent — the model is told the image could not be read; if the gateway is too busy to prepare the image (or preparing it times out), it is told image editing is temporarily unavailable.
- The image returned by the model is accepted only if it is a valid PNG and at most 12 MB; anything else is rejected and nothing is stored.
- The stored image's content type is always
image/png(never taken from the upstream response). - Media returned by the model as an expiring URL (rather than inline bytes — e.g. a provider that answers with a short-lived signed CloudFront download link) is fetched once, server-side, through an SSRF-safe, fail-closed media-fetch path before the link expires. That fetch treats the URL and the response as untrusted even though the provider call was authenticated:
- Only an
https://URL is fetched. A private, loopback, or link-local host (e.g.127.0.0.1,10.0.0.0/8,169.254.169.254, or a DNS name that resolves to one) is blocked with no connection made, and every redirect hop is re-validated against the pinned dial IP; noAuthorizationheader is ever sent, so a redirect to another host leaks no credential. - The response content-type must be on the per-kind allowlist — images:
image/png,image/jpeg,image/webp,image/gif; video:video/mp4,video/webm— and the leading magic bytes must match that declared type. An absent content-type is rejected exactly like a disallowed one (an undeclared type is never treated more permissively than a declared one), and a body whose bytes disagree with its content-type (for exampletext/htmlorimage/svg+xmllabelledimage/png) is rejected.image/svg+xmlis never accepted. - The body is size-capped (25 MiB for an image, 150 MiB for a video) and read with a hard wall; an oversized body, an HTTP error (
4xx/5xx, including a403/expired signed URL), a timeout, or an empty2xxbody is rejected. On any rejection nothing is stored and the turn surfaces the failure rather than a broken asset.
- Only an
When generation or editing fails, the tool returns an error message to the model rather than an image, and the assistant continues the turn. Editing distinguishes an invalid/unsupported uploaded image (the model is told the image could not be edited) from a temporarily unavailable service (a transient upstream failure).
When the image service is busy
The EU image model renders one image at a time per server, so a burst of image requests can find it busy. The gateway then:
- Waits briefly and tries once more. When the image service answers "busy" (HTTP
429or503), the gateway waits 3–6 seconds (a random share, so simultaneous requests do not retry together) — or the time the service itself asks for, if it asks for 20 seconds or less (a wait request the gateway cannot read is treated like a long one: no second try) — and sends the request one more time. It never retries more than once, never when the service asks for a longer wait, and only while the answer still has enough time left (at least about 90 seconds of the turn's time budget; the whole image request, both tries and the wait, ends within about two and a half minutes). It does not retry after you closed the chat — except inside a delegated agent's run, which cannot notice the closed chat and may still make its one retry. Any other failure (a timeout, an error answer, a malformed reply) is not retried. - Tells the truth if it is still busy. The assistant is told that the image service is busy or temporarily unavailable, that nothing was generated (or edited), and to suggest trying again in a minute — it never presents an image that does not exist. The rest of the answer (and of a multi-agent run) makes no further image request: every later image call of the same request answers "busy" at once.
- Records it for the operators. Each request to the image service is logged as its own entry in the request's legs (kind
image_generationorimage_edit, with the status andbusywhen it was refused). A request that stays busy is also reported to the platform's error queue, naming the organisation, so capacity problems are visible per tenant.
Reproducible images (seed)
Every newly generated or edited image has a seed: a number that, together with the prompt, the size and the settings, determines the picture. The same seed with the same prompt, size and settings gives the same image on the same image service; change only the seed and you get a variation of the same idea.
- Always recorded and shown. If neither you nor the assistant chose a seed, the gateway picks a random one. The seed the gateway actually sent to the image service is stored with the image and shown under it in the chat, together with its size (for example 1024x1024 · Seed 1234). The assistant is told the seed too, so it can repeat it.
- Asking for it again. Say for example "again with seed 1234" or "the same picture, but with seed 1235". The assistant then passes that seed. Without a seed the assistant leaves it out and you get a new random image.
- What must stay the same. The same seed reproduces an image only with the same prompt, the same size and the same image model and service version. The prompt that counts is the description the assistant sent to the image model, which is usually not exactly your wording. In a later message the assistant no longer sees that exact description (it is not part of the chat history), so "again with seed 1234" there gives an image with the same seed and a re-written description: often close, but not guaranteed identical. For an exact repeat, ask in the same message, or give the full description yourself and ask the assistant to use it word for word.
- How exact it is. Measured on the self-hosted EU image model: the same seed, prompt and size produced bit-for-bit identical images, at 512x512 and at 1024x1024, on each of the image service's servers it was measured on (repeated runs, alternating between two servers). This holds as long as the image service itself is unchanged; a new model version or changed server-side settings can change the image for the same seed.
- Editing. A seed works on image edits too. An edit without a seed gets a random one, which is stored and shown like the seed of a generated image. The same source image, seed, prompt and settings should give the same edit on the same image service. Each stored edit also records which image it was made from (see Retrieving a generated image).
- Steps and guidance. The assistant can also set
num_inference_stepsandguidance_scale(see the tool contract), for example when you ask for "40 steps" or "guidance 5.5". They are stored with the image, like the seed, and shown beside it on the image card (for example "Seed 1234 · 40 steps · Guidance 5.5"). When the assistant did not send one, nothing is stored for it and the image service's default applied; the card then shows nothing for that setting. A seed reproduces an image only together with the same settings, so repeat them with the seed (the assistant is told them in the same chat and can repeat them). - Private chats. An image in a private (unsaved) chat is never stored. Its seed appears in its file name (for example
image-seed-1234.png), and the assistant is told it. - Per-request record. Every request the gateway sends to the image service — a generation or an edit, each attempt of the one busy retry counted separately — is also a row in the request's legs: kind, model, status, error class and latency, no prompt and no image (request-log legs). A background removal goes to its own service and is one leg per request. The seed and the source hashes are not repeated there; they stay with the stored image.
- Where the exact description is kept. The description the assistant sent to the image model is the tool call's
promptargument, sent unchanged. The gateway stores no copy of its own; it is part of the stored tool call wherever the gateway already keeps tool calls: the playground trace when the gateway records bodies (tracing.include_bodies, never for a private chat), the turn replay record (kept by default for 30 days), and — encrypted, for a short time, only when the model failed after the tool ran — the turn's resume state. The tool's reply to the assistant repeats it too.
Remove the background of an image
When the platform offers it, the assistant can also remove the background of an image and return it as a PNG with a transparent background. Ask for it in words ("remove the background", "cut out the person") with an image attached, or use the Remove background button. The background removal itself runs on a self-hosted model (BiRefNet) on Myra's own EU GPU servers: the tool sends the image to no third party, and a picked image (by the button) is loaded by the gateway, not sent to the language model again. An image you attach to your message is, like any attachment, part of the message the chat model receives.
The button. A Remove background button appears next to Animate under a generated image and under an image you uploaded in a saved message. Like Animate, it sends nothing: it places an editable draft ("Remove the background of image <id>.") in the message box, and you press Send. The gateway then loads the image itself from the conversation. The button is shown only when it can work:
- you own the conversation;
- background removal is available for the next reply: on the gateway the chat uses, or, when the chat picks its gateway automatically, on every production gateway it could route to; never in a local-only project;
- the image is a PNG, JPEG or WebP of at most 10 MiB (not a GIF);
- for an upload, it is the last image of that message (the one the gateway would use).
The gateway uses an image id the assistant passes only when your message names it (the button's draft does). If the assistant picks an image of the chat on its own, the image is offered for confirmation instead ("Use this image?", see above).
Enabling it. Two switches, both required: the gateway's Image Generation switch (the same one as above), and the platform setting background_removal_available (default off; a platform admin sets it with PUT /admin/v1/settings/background_removal_available and { "value": true } — see the settings API). The client must also send x-aig-image-gen (the web chat always does). Without them the tool is not offered and the button is hidden.
Result. The PNG appears in the reply like a generated image (stored with your saved conversation; delivered only live in a private chat). The longest side is at most 2048 pixels; a larger image is scaled down. The gateway reads the returned PNG itself: the assistant is told the result is a "transparent PNG" only when the file's format carries an alpha channel or a transparency chunk (a palette/colour-key transparency entry). A result that is fully opaque is reported as such, and the assistant says plainly that it is not transparent; a result whose transparency cannot be confirmed is reported as unconfirmed, never as transparent. The same check applies to images the assistant generates or edits (for example when you ask for a transparent background): the assistant is only told the result is transparent when the file is. It counts toward the limit of 4 images per turn, and the assistant may call the tool at most twice per reply.
The tool's arguments, checks and refusals are listed in the inference API reference.
Retrieving a generated image
Each assistant message that produced images carries an images array of { id, mime_type, size }. The bytes are fetched by id:
The response is JSON { id, mime_type, size, data, seed, source_sha256, sent_sha256, num_inference_steps, guidance_scale } where data is base64-encoded PNG bytes. Access is scoped to the caller's own conversation and to images belonging to that conversation; a mismatched image id returns 404.
The fields after data are the image's reproducibility record. Each is null when nothing was recorded: for images made before this record existed, for images produced by other tools, for the seed of an edit made before edits were seeded, and for num_inference_steps and guidance_scale when the assistant did not send them (the image service's default applied). num_inference_steps is an integer from 1 to 50, guidance_scale a number from 0 to 20 (0 is a real value, not "none").
seed: the seed sent to the image service for this image (an integer from 0 to 4294967295).source_sha256: for an edit, the SHA-256 (lowercase hex) of the source image as the gateway received it. That is the attached image, or the image from the chat you confirmed. The browser may already have shrunk a very large photo (over about 7 MB) before sending it.sent_sha256: for an edit, the SHA-256 of the image bytes the gateway actually sent to the image model, after its re-encoding (see the editing checks above). Together the two hashes prove which image was edited.
Repeated identical calls
An identical repeat of a successful generate_image call in the same reply is not run again, so one reply never pays for the same image twice. The assistant is told the image already exists; a request that should produce another image must change the arguments (for example the description or the seed).
Data lifecycle
Generated images are stored with their conversation and are deleted when the conversation (or the owning account) is deleted, including under a GDPR Art. 17 erasure. Images generated during a turn that is never persisted (for example, the user navigates away mid-stream) are swept by a periodic reaper. An image delivered live in a private (ghost) conversation is never stored in the first place — there is nothing to reap, and it is gone when the conversation is left.