image_generate tool creates and edits images through your configured
providers. In chat sessions it runs asynchronously: OpenClaw records a
background task, returns the task id immediately, and wakes the agent when
the provider finishes. The completion agent follows the session’s normal
visible-reply mode: automatic final reply delivery when configured, or
message(action="send") when the session requires the message tool. If the
requester session is inactive or its active wake fails, OpenClaw sends an
idempotent direct fallback with the generated images so the result is not
lost.
The tool only appears when at least one image-generation provider is
available. If you do not see
image_generate in your agent’s tools,
configure agents.defaults.imageGenerationModel, set up a provider API key,
or sign in with OpenAI ChatGPT/Codex OAuth.Quick start
Configure auth
Set an API key for at least one provider (for example
OPENAI_API_KEY,
GEMINI_API_KEY, OPENROUTER_API_KEY) or sign in with OpenAI Codex OAuth.Pick a default model (optional)
openai/gpt-image-2 model ref. When an
openai OAuth profile is configured, OpenClaw routes image requests
through that OAuth profile instead of first trying OPENAI_API_KEY.
Explicit models.providers.openai config (API key, custom/Azure base URL)
opts back into the direct OpenAI Images API route.Ask the agent
“Generate an image of a friendly robot mascot.”The agent calls
image_generate automatically. No tool allow-listing
needed - it is enabled by default when a provider is available. The tool
returns a background task id, then the completion agent sends the
generated attachment through the message tool when it is ready.Common routes
| Goal | Model ref | Auth |
|---|---|---|
| OpenAI image generation with API billing | openai/gpt-image-2 | OPENAI_API_KEY |
| OpenAI image generation with Codex subscription auth | openai/gpt-image-2 | OpenAI ChatGPT/Codex OAuth |
| OpenAI transparent-background PNG/WebP | openai/gpt-image-1.5 | OPENAI_API_KEY or OpenAI Codex OAuth |
| DeepInfra image generation | deepinfra/black-forest-labs/FLUX-1-schnell | DEEPINFRA_API_KEY |
| fal Krea 2 expressive/style-directed generation | fal/krea/v2/medium/text-to-image | FAL_KEY |
| OpenRouter image generation | openrouter/google/gemini-3.1-flash-image-preview | OPENROUTER_API_KEY |
| LiteLLM image generation | litellm/gpt-image-2 | LITELLM_API_KEY |
| Microsoft Foundry MAI image generation | microsoft-foundry/<deployment-name> | AZURE_OPENAI_API_KEY or Entra ID |
| Google Gemini image generation | google/gemini-3.1-flash-image-preview | GEMINI_API_KEY or GOOGLE_API_KEY |
image
for one reference or images for multiple. For Krea 2 models on fal, those
references are sent as style references instead of edit inputs.
Provider-supported output hints such as quality, outputFormat, and
background are forwarded when available and reported as ignored when a
provider does not declare support. Bundled transparent-background support is
OpenAI-specific; other providers may still preserve PNG alpha if their
backend emits it.
Supported providers
| Provider | Default model | Edit support | Auth |
|---|---|---|---|
| ComfyUI | workflow | Yes (1 image, workflow-configured) | COMFY_API_KEY or COMFY_CLOUD_API_KEY for cloud |
| DeepInfra | black-forest-labs/FLUX-1-schnell | Yes (1 image) | DEEPINFRA_API_KEY |
| fal | fal-ai/flux/dev | Yes (model-specific limits) | FAL_KEY |
gemini-3.1-flash-image-preview | Yes (up to 5 images) | GEMINI_API_KEY or GOOGLE_API_KEY | |
| LiteLLM | gpt-image-2 | Yes (up to 5 input images) | LITELLM_API_KEY |
| Microsoft Foundry | <deployment-name> | Yes (MAI-Image-2.5 models only) | AZURE_OPENAI_API_KEY or Entra ID (az login) |
| MiniMax | image-01 | Yes (subject reference) | MINIMAX_API_KEY or MiniMax OAuth (minimax-portal) |
| OpenAI | gpt-image-2 | Yes (up to 5 images) | OPENAI_API_KEY or OpenAI ChatGPT/Codex OAuth |
| OpenRouter | google/gemini-3.1-flash-image-preview | Yes (up to 5 input images) | OPENROUTER_API_KEY |
| Vydra | grok-imagine | No | VYDRA_API_KEY |
| xAI | grok-imagine-image | Yes (up to 5 images) | XAI_API_KEY |
action: "list" to inspect available providers and models at runtime:
action: "status" to inspect the active image-generation task for the
current session:
Provider capabilities
| Capability | ComfyUI | DeepInfra | fal | Microsoft Foundry | MiniMax | OpenAI | Vydra | xAI | |
|---|---|---|---|---|---|---|---|---|---|
| Generate (max count) | 1 | 4 | 4 | 4 | 1 | 9 | 4 | 1 | 4 |
| Edit / reference | 1 image (workflow) | 1 image | Flux: 1; GPT: 10; Krea style refs: 10; NB2: 14 | Up to 5 images | 1 image | 1 image (subject ref) | Up to 5 images | - | Up to 5 images |
| Size control | - | ✓ | ✓ | ✓ | ✓ | - | Up to 4K | - | - |
| Aspect ratio | - | - | ✓ | ✓ | - | ✓ | - | - | ✓ |
| Resolution (1K/2K/4K) | - | - | ✓ | ✓ | - | - | - | - | 1K, 2K |
Tool parameters
Image generation prompt. Required for
action: "generate".Use
"status" to inspect the active session task or "list" to inspect
available providers and models at runtime.Provider/model override (e.g.
openai/gpt-image-2). Use
openai/gpt-image-1.5 for transparent OpenAI backgrounds.Single reference image path or URL for edit mode.
Multiple reference images for edit mode or style-reference models (up to 14
through the shared tool; provider-specific limits still apply).
Size hint:
1024x1024, 1536x1024, 1024x1536, 2048x2048, 3840x2160.Aspect ratio:
1:1, 2:1, 20:9, 19.5:9, 2:3, 3:2, 2.35:1, 3:4,
4:3, 4:5, 5:4, 9:16, 9:19.5, 9:20, 16:9, 21:9, 1:2, 4:1,
1:4, 8:1, 1:8. Providers validate their model-specific subset.Resolution hint.
Quality hint when the provider supports it.
Output format hint when the provider supports it.
Background hint when the provider supports it. Use
transparent with
outputFormat: "png" or "webp" for transparency-capable providers.Number of images to generate (1-4).
Optional provider request timeout in milliseconds. When Codex calls
image_generate through dynamic tools, this per-call value still overrides
the configured default and is capped at 600000 ms.Output filename hint.
OpenAI-only hints:
background, moderation, outputCompression, and user.fal Krea 2 creativity control. Defaults to
medium.Not all providers support all parameters. When a fallback provider supports a
nearby geometry option instead of the exact requested one, OpenClaw remaps to
the closest supported size, aspect ratio, or resolution before submission.
Unsupported output hints are dropped for providers that do not declare
support and reported in the tool result. Tool results report the applied
settings;
details.normalization captures any requested-to-applied
translation.Configuration
Model selection
Provider selection order
OpenClaw tries providers in this order:modelparameter from the tool call (if the agent specifies one).imageGenerationModel.primaryfrom config.imageGenerationModel.fallbacksin order.- Auto-detection - auth-backed provider defaults only:
- current default provider first;
- remaining registered image-generation providers in provider-id order.
Per-call model overrides are exact
Per-call model overrides are exact
A per-call
model override tries only that provider/model and does
not continue to configured primary/fallback or auto-detected providers.Auto-detection is auth-aware
Auto-detection is auth-aware
A provider default only enters the candidate list when OpenClaw can
actually authenticate that provider. Set
agents.defaults.mediaGenerationAutoProviderFallback: false to use only
explicit model, primary, and fallbacks entries.Timeouts
Timeouts
Set
agents.defaults.imageGenerationModel.timeoutMs for slow image
backends. A per-call timeoutMs tool parameter overrides the configured
default, and configured defaults override plugin-authored provider
defaults. Google and OpenRouter hosted image providers use 180 second
defaults; Microsoft Foundry MAI, xAI, and Azure OpenAI image generation use
600 seconds. Codex dynamic-tool calls use a 120 second image_generate
bridge default and honor the same timeout budget when configured, bounded
by OpenClaw’s 600000 ms dynamic-tool bridge maximum.Inspect at runtime
Inspect at runtime
Use
action: "list" to inspect the currently registered providers,
their default models, and auth env-var hints.Image editing
OpenAI, OpenRouter, Google, DeepInfra, fal, Microsoft Foundry, MiniMax, ComfyUI, and xAI support editing reference images. Krea 2 models on fal use the sameimage / images fields as style references instead of edit
inputs. Pass a reference image path or URL:
images parameter. fal supports 1 reference image for Flux image-to-image,
up to 10 for GPT Image 2 edits, up to 10 style references for Krea 2, and up
to 14 for Nano Banana 2 edits. Microsoft Foundry, MiniMax, and ComfyUI
support 1.
Provider deep dives
OpenAI gpt-image-2 (and gpt-image-1.5)
OpenAI gpt-image-2 (and gpt-image-1.5)
OpenAI image generation defaults to
openai/gpt-image-2. If an
openai OAuth profile is configured, OpenClaw reuses the same
OAuth profile used by Codex subscription chat models and sends the
image request through the Codex Responses backend. Legacy Codex base
URLs such as https://chatgpt.com/backend-api are canonicalized to
https://chatgpt.com/backend-api/codex for image requests. OpenClaw
does not silently fall back to OPENAI_API_KEY for that request -
to force direct OpenAI Images API routing, configure
models.providers.openai explicitly with an API key, custom base URL,
or Azure endpoint.The openai/gpt-image-1.5, openai/gpt-image-1, and
openai/gpt-image-1-mini models can still be selected explicitly. Use
gpt-image-1.5 for transparent-background PNG/WebP output; the current
gpt-image-2 API rejects background: "transparent".gpt-image-2 supports both text-to-image generation and
reference-image editing through the same image_generate tool.
OpenClaw forwards prompt, count, size, quality, outputFormat,
and reference images to OpenAI. OpenAI does not receive
aspectRatio or resolution directly; when possible OpenClaw maps
those into a supported size, otherwise the tool reports them as
ignored overrides.OpenAI-specific options live under the openai object:openai.background accepts transparent, opaque, or auto;
transparent outputs require outputFormat png or webp and a
transparency-capable OpenAI image model. OpenClaw routes default
gpt-image-2 transparent-background requests to gpt-image-1.5.
openai.outputCompression applies to JPEG/WebP outputs and is ignored
for PNG outputs.The top-level background hint is provider-neutral and currently maps
to the same OpenAI background request field when the OpenAI provider
is selected. Providers that do not declare background support return
it in ignoredOverrides instead of receiving the unsupported parameter.To route OpenAI image generation through an Azure OpenAI deployment
instead of api.openai.com, see
Azure OpenAI endpoints.Microsoft Foundry MAI image models
Microsoft Foundry MAI image models
Microsoft Foundry image generation uses deployed MAI image deployment names
under the The provider uses Microsoft Foundry’s MAI API, not the OpenAI Images API:
microsoft-foundry/ provider prefix. There is no provider-level
default model because the MAI API expects your deployment name in the
model field:- Generation endpoint:
/mai/v1/images/generations - Edit endpoint:
/mai/v1/images/edits - Auth:
AZURE_OPENAI_API_KEY/ provider API key, or Entra ID throughaz login - Output: one PNG image
- Size: default
1024x1024; width and height must each be at least 768 px, and total pixels must be at most 1,048,576 - Edits: one PNG or JPEG reference image, supported only by
MAI-Image-2.5-FlashandMAI-Image-2.5deployments
MAI-Image-2.5-Flash or MAI-Image-2.5.Current MAI image models are MAI-Image-2.5-Flash, MAI-Image-2.5,
MAI-Image-2e, and MAI-Image-2. See
Microsoft Foundry plugin for setup
and chat-model behavior.OpenRouter image models
OpenRouter image models
OpenRouter image generation uses the same OpenClaw forwards
OPENROUTER_API_KEY and
routes through OpenRouter’s chat completions image API. Select
OpenRouter image models with the openrouter/ prefix:prompt, count, reference images, and
Gemini-compatible aspectRatio / resolution hints to OpenRouter.
Current built-in OpenRouter image model shortcuts include
google/gemini-3.1-flash-image-preview,
google/gemini-3-pro-image-preview, and openai/gpt-5.4-image-2. Use
action: "list" to see what your configured plugin exposes.fal Krea 2
fal Krea 2
Krea 2 models on fal use fal’s native Krea schema instead of the generic
Krea 2 currently returns one image per request. Prefer
image_size schema used by Flux. OpenClaw sends:aspect_ratiofor aspect-ratio hintscreativity, defaulting tomediumimage_style_referenceswhenimageorimagesare supplied
aspectRatio for
Krea; OpenClaw maps size to the closest supported Krea aspect ratio and
rejects resolution for Krea rather than dropping it. Use fal.creativity
when you want a native Krea creativity level:MiniMax dual-auth
MiniMax dual-auth
MiniMax image generation is available through both bundled MiniMax
auth paths:
minimax/image-01for API-key setupsminimax-portal/image-01for OAuth setups
xAI grok-imagine-image
xAI grok-imagine-image
The bundled xAI provider uses
/v1/images/generations for prompt-only
requests and /v1/images/edits when image or images is present.- Models:
xai/grok-imagine-image,xai/grok-imagine-image-quality - Count: up to 4
- References: one
imageor up to fiveimages - Aspect ratios:
1:1,16:9,9:16,4:3,3:4,2:3,3:2 - Resolutions:
1K,2K - Outputs: returned as OpenClaw-managed image attachments
quality, mask,
user, or extra native-only aspect ratios until those controls exist
in the shared cross-provider image_generate contract.Examples
- Generate (4K landscape)
- Generate (transparent PNG)
- Generate (OpenAI low quality)
- Generate (two square)
- Edit (one reference)
- Edit (multiple references)
- Krea style references
--output-format, --background, --quality, and
--openai-moderation flags are available on openclaw infer image edit;
--openai-background remains as an OpenAI-specific alias. Bundled providers
other than OpenAI do not declare explicit background control today, so
background: "transparent" is reported as ignored for them.
Related
- Tools overview - all available agent tools
- ComfyUI - local ComfyUI and Comfy Cloud workflow setup
- fal - fal image and video provider setup
- Google (Gemini) - Gemini image provider setup
- Microsoft Foundry plugin - Microsoft Foundry chat and MAI image setup
- MiniMax - MiniMax image provider setup
- OpenAI - OpenAI Images provider setup
- Vydra - Vydra image, video, and speech setup
- xAI - Grok image, video, search, code execution, and TTS setup
- Configuration reference -
imageGenerationModelconfig - Models - model configuration and failover