Skip to content

Image Generation

The image_generate tool lets the agent create and edit images using your configured providers. Generated images are delivered automatically as media attachments in the agent’s reply.

  1. Set an API key for at least one provider (for example OPENAI_API_KEY or GEMINI_API_KEY).
  2. Optionally set your preferred model:
{
agents: {
defaults: {
imageGenerationModel: "openai/gpt-image-1",
},
},
}
  1. Ask the agent: “Generate an image of a friendly lobster mascot.”

The agent calls image_generate automatically. No tool allow-listing needed — it’s enabled by default when a provider is available.

ProviderDefault modelEdit supportAPI key
OpenAIgpt-image-1Yes (up to 5 images)OPENAI_API_KEY
Googlegemini-3.1-flash-image-previewYesGEMINI_API_KEY or GOOGLE_API_KEY
falfal-ai/flux/devYesFAL_KEY
MiniMaximage-01Yes (subject reference)MINIMAX_API_KEY

Use action: "list" to inspect available providers and models at runtime:

/tool image_generate action=list
ParameterTypeDescription
promptstringImage generation prompt (required for action: "generate")
actionstring"generate" (default) or "list" to inspect providers
modelstringProvider/model override, e.g. openai/gpt-image-1
imagestringSingle reference image path or URL for edit mode
imagesstring[]Multiple reference images for edit mode (up to 5)
sizestringSize hint: 1024x1024, 1536x1024, 1024x1536, 1024x1792, 1792x1024
aspectRatiostringAspect ratio: 1:1, 2:3, 3:2, 3:4, 4:3, 4:5, 5:4, 9:16, 16:9, 21:9
resolutionstringResolution hint: 1K, 2K, or 4K
countnumberNumber of images to generate (1–4)
filenamestringOutput filename hint

Not all providers support all parameters. The tool passes what each provider supports and ignores the rest.

{
agents: {
defaults: {
// String form: primary model only
imageGenerationModel: "google/gemini-3-pro-image-preview",
// Object form: primary + ordered fallbacks
imageGenerationModel: {
primary: "openai/gpt-image-1",
fallbacks: ["google/gemini-3.1-flash-image-preview", "fal/fal-ai/flux/dev"],
},
},
},
}

When generating an image, OpenClaw tries providers in this order:

  1. model parameter from the tool call (if the agent specifies one)
  2. imageGenerationModel.primary from config
  3. imageGenerationModel.fallbacks in order
  4. Auto-detection — queries all registered providers for defaults, preferring: configured primary provider, then OpenAI, then Google, then others

If a provider fails (auth error, rate limit, etc.), the next candidate is tried automatically. If all fail, the error includes details from each attempt.

OpenAI, Google, fal, and MiniMax support editing reference images. Pass a reference image path or URL:

"Generate a watercolor version of this photo" + image: "/path/to/photo.jpg"

OpenAI and Google support up to 5 reference images via the images parameter. fal and MiniMax support 1.

CapabilityOpenAIGooglefalMiniMax
GenerateYes (up to 4)Yes (up to 4)Yes (up to 4)Yes (up to 9)
Edit/referenceYes (up to 5 images)Yes (up to 5 images)Yes (1 image)Yes (1 image, subject ref)
Size controlYesYesYesNo
Aspect ratioNoYesYes (generate only)Yes
Resolution (1K/2K/4K)NoYesYesNo