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 safeenables builtins;--tools nonehidesgenerate_image. - At least one configured image provider. OpenAI uses
RKAT_OPENAI_API_KEYorOPENAI_API_KEY; Azure OpenAI usesAZURE_OPENAI_API_KEY,AZURE_OPENAI_ENDPOINT, andAZURE_OPENAI_IMAGE_GENERATION_DEPLOYMENT; Gemini usesRKAT_GEMINI_API_KEY,GEMINI_API_KEY, orGOOGLE_API_KEY. - A blob store. CLI, REST, RPC, MCP, and persistent SDK-backed sessions wire this automatically through the runtime-backed surface.
countmust be1. Multiple image output is rejected today withunsupported_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:images[].blob_ref.blob_id. Save the generated image with:
Request Shape
The tool accepts one top-level field,request. For normal use, pass the simple request shape:
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:
generate_image result:
Fields
Target Selection
By default,target is auto.
- If a configured
image_generation_providerexists (mob definition top-level key or per-profile field inmob.toml),autoresolves 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,
autouses that provider’s default image target. - If neither applies, set
providerexplicitly per request. - To force a model, pass both
providerandmodel.
Provider Options
OpenAI
provider: "openai" uses the OpenAI image default, currently gpt-image-2.
Meerkat fields and OpenAI lowering:
Model behavior:
gpt-image-2uses the hosted Responses image tool internally, but callers still pass Meerkat’sgenerate_imagerequest shape.- On the
azure_openaibackend, hosted image generation requires backend optionimage_generation_deployment(for examplegpt-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-2accepts flexibleWIDTHxHEIGHTsizes 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 include1024x1024,1536x1024,1024x1536,2048x2048,2048x1152,3840x2160, and2160x3840.- Do not copy raw Responses API JSON into
provider_params. Use Meerkat’s universalsize,quality,format, andintentfields, and reserveprovider_paramsfor the advanced OpenAI overrides above. - For fresh/current image-only requests, prefer passing
provider_params.web_searchtogenerate_imageover doing a separate search turn first. - Do not pass
background: "transparent"forgpt-image-2; OpenAI rejects it. Do not passinput_fidelity; Meerkat’s OpenAI adapter uses a closed provider-params shape and rejects unknown fields. - Other OpenAI-owned
gpt-image*ordall-e*models use the Images API path. - The Images API path currently rejects edit requests, reference images,
action,reasoning_effort, andweb_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-previewgemini-3-pro-image-previewgemini-2.5-flash-image
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:
Troubleshooting
Related Docs
- Tools for how builtins are enabled and scoped.
- Built-in tools reference for the concise parameter reference.
- Providers for provider credentials and model catalog behavior.
- Built-in tools reference for the model-facing tool contract.
