@image tool generates and edits images via the llm/imagegen package, local/keyless-first and multi-provider.
Backend selection (local first)
imagegen.NewFromEnv picks one, degrading to null when nothing is configured:
CHATCLI_IMAGE_PROVIDER=sdwebui→ local Stable Diffusion WebUI (/sdapi/v1/txt2img, defaulthttp://localhost:7860). Keyless — the preferred path.CHATCLI_IMAGE_URL→ an OpenAI-compatible endpoint (/images/generations). Covers OpenAI, LocalAI and similar.OPENAI_API_KEY→ OpenAI Images API (defaultgpt-image-1).CHATCLI_IMAGE_PROVIDER=responses(oropenai+CHATCLI_IMAGE_API=responses) → OpenAI Responses API, where a chat model likegpt-5.5generates the image via theimage_generationtool.GOOGLEAI_API_KEY/GEMINI_API_KEY→ native Google (Imagen:predictto generate; Gemini image / “Nano Banana”:generateContentto edit).XAI_API_KEY→ native xAI grok-image / Aurora (OpenAI shape, omitssize). Generate only.CHATCLI_IMAGE_PROVIDER=bedrock→ AWS Bedrock (Nova Canvas / Titan Image / Stability viaInvokeModel, reusing the chat provider’s credential chain).
CHATCLI_IMAGE_PROVIDER pins the backend (sdwebui|url|openai|responses|google|xai|zai|minimax|bedrock); CHATCLI_IMAGE_API selects images|responses on OpenAI; CHATCLI_IMAGE_MODEL sets the model.
The model is inherited by both generation AND editing.
@image gen and @image edit read the same CHATCLI_IMAGE_MODEL/CHATCLI_IMAGE_PROVIDER — one /model-image serves both. You never configure “one model to create and another to edit”.The @image tool
edit accepts image (path), mask (optional PNG for inpainting), strength (0..1 — how much to change). The result reports the output file path(s).
Multi-provider editing (not locked to one)
Editing is a per-API capability — not every generation backend has an edit endpoint.@image edit is capability-gated: editing backends get Edit; generation-only ones refuse cleanly (and route, see below).
Inheritance and automatic routing
Editing inherits the active provider/model. Only when the active backend can’t edit does@image edit route to an edit-capable fallback — and says so explicitly:
ℹ️ Image backendFallback order (each credential-gated, never routing to something that can’t run):"xai"can’t edit images; routed to"sdwebui"for this edit. SetCHATCLI_IMAGE_EDIT_PROVIDERto pin a different one.
Models & per-command config
gpt-image-2, gpt-image-1.5, gpt-image-1, gpt-image-1-mini; OpenAI Responses gpt-5.5, gpt-5; Google imagen-3.0-generate-002 (generate) / gemini-2.5-flash-image (edit); xAI grok-2-image; Bedrock amazon.nova-canvas-v1:0, stability.stable-image-core-v1:1, stability.sd3-5-large-v1:0.
Formats & details
- OpenAI edits accepts
image/jpeg,image/png,image/webp(notgif). The multipart part’sContent-Typeis sent correctly from the image bytes. - SD WebUI img2img uses
denoising_strength(mapped fromstrength); default0.6(visible change while preserving structure). - Bedrock Stability uses
mode: image-to-image+strength; Nova/Titan useIMAGE_VARIATIONwithsimilarityStrength.
Privacy & cost
- Local Stable Diffusion WebUI is keyless and generates and edits on your machine — ideal for privacy and zero cost.
- Cloud backends use the user’s own key.
- Confirm before generating/editing large batches; mention cost when relevant.
Related
- Image Input (Vision) — the model sees images you attach
- Text-to-Speech & Voice
- Chat Gateway