Skip to main content
Image generation in Meerkat is exposed as the session-scoped generate_image builtin tool. The model asks for an image during a normal turn, Meerkat routes the request to a configured image provider, stores generated bytes in the realm blob store, and returns durable image references back into the session. This is not a standalone image/generate RPC. Use it by running a session with builtins enabled and telling the agent to call generate_image when an image artifact is required.

Requirements

  • A runtime-backed session surface with builtins enabled. The CLI default --tools safe enables builtins; --tools none hides generate_image.
  • At least one configured image provider. OpenAI uses RKAT_OPENAI_API_KEY or OPENAI_API_KEY; Azure OpenAI uses AZURE_OPENAI_API_KEY, AZURE_OPENAI_ENDPOINT, and AZURE_OPENAI_IMAGE_GENERATION_DEPLOYMENT; Gemini uses RKAT_GEMINI_API_KEY, GEMINI_API_KEY, or GOOGLE_API_KEY.
  • A blob store. CLI, REST, RPC, MCP, and persistent SDK-backed sessions wire this automatically through the runtime-backed surface.
  • count must be 1. Multiple image output is rejected today with unsupported_count; run multiple operations if you need several variants.
generate_image is separate from view_image. view_image reads an existing file into the model as image input. generate_image creates a new assistant-owned image and stores it as a blob. When the model needs to save a generated blob to disk during the same run, it can call blob_save_file.

CLI quickstart

The safest way to force a first turn to use image generation is to allow only the image tool for that turn:
When the tool succeeds, the tool result includes images[].blob_ref.blob_id. Save the generated image with:
You can also ask the agent to save the image itself:
Inspect the stored payload instead of writing raw bytes:

Request Shape

The tool accepts one top-level field, request. For normal use, pass the simple request shape:
This is the Meerkat generate_image tool input, not a raw OpenAI Responses API request. Meerkat lowers universal fields such as size, quality, and format into the selected provider’s native request. For OpenAI, format becomes the provider-side output_format option. For edits, set intent to edit, provide an instruction, and include at least one source_images entry:
Reference an existing blob when the source image did not come from a previous generate_image result:

Fields

Target Selection

By default, target is auto.
  • If a configured image_generation_provider exists (mob definition top-level key or per-profile field in mob.toml), auto resolves against that provider’s default image target — even when the session’s text provider (for example Anthropic) has no image profile.
  • Otherwise, if the current session model belongs to a provider with an image profile, auto uses that provider’s default image target.
  • If neither applies, set provider explicitly per request.
  • To force a model, pass both provider and model.
OpenAI default:
Gemini default:

Provider Options

OpenAI

provider: "openai" uses the OpenAI image default, currently gpt-image-2. Meerkat fields and OpenAI lowering: Model behavior:
  • gpt-image-2 uses the hosted Responses image tool internally, but callers still pass Meerkat’s generate_image request shape.
  • On the azure_openai backend, hosted image generation requires backend option image_generation_deployment (for example gpt-image-2). The session model remains the Azure text deployment name, and Meerkat selects the image deployment with Azure’s Responses image-generation header.
  • gpt-image-2 accepts flexible WIDTHxHEIGHT sizes when they satisfy OpenAI’s constraints: both edges are multiples of 16 px, max edge is 3840 px, aspect ratio is at most 3:1, and total pixels are between 655,360 and 8,294,400. Common values include 1024x1024, 1536x1024, 1024x1536, 2048x2048, 2048x1152, 3840x2160, and 2160x3840.
  • Do not copy raw Responses API JSON into provider_params. Use Meerkat’s universal size, quality, format, and intent fields, and reserve provider_params for the advanced OpenAI overrides above.
  • For fresh/current image-only requests, prefer passing provider_params.web_search to generate_image over doing a separate search turn first.
  • Do not pass background: "transparent" for gpt-image-2; OpenAI rejects it. Do not pass input_fidelity; Meerkat’s OpenAI adapter uses a closed provider-params shape and rejects unknown fields.
  • Other OpenAI-owned gpt-image* or dall-e* models use the Images API path.
  • The Images API path currently rejects edit requests, reference images, action, reasoning_effort, and web_search.

Gemini

provider: "gemini" and provider: "google" use the Gemini image default, currently gemini-3.1-flash-image-preview. Supported Gemini image models:
  • gemini-3.1-flash-image-preview
  • gemini-3-pro-image-preview
  • gemini-2.5-flash-image
Gemini provider_params: Gemini image generation runs through a scoped image-model turn internally. The user and model still use one generate_image operation; they do not need to call switch_turn.

Result Shape

generate_image returns structured JSON:
Important fields:

Troubleshooting