* docs: improve readability and remove internal technical details from user docs * docs: expand user-doc cleanup to remote instances, deployment, providers, MCP presets, my-tool, and add concept diagrams * docs: streamline root README and SECURITY guide for readability * docs: move Why nanobot before Start Here and highlight lightweight footprint and WebUI
9.7 KiB
Image Generation
nanobot can generate new images and edit existing ones directly in chat. Image generation is off by default—enable it in Settings, then describe the image you want in plain language.
Quick Setup
In the WebUI:
- Make sure your image provider is added under Settings → Models → Provider → Add provider.
- Open Settings → Capabilities → Image generation.
- Choose the provider and image model, turn on Image generation, and click Save.
- Ask nanobot for a test image in chat (if the WebUI asks for a restart, restart first).
Manual configuration
Merge this snippet into ~/.nanobot/config.json, replacing provider and model with any supported image provider and model you use:
{
"providers": {
"openrouter": {
"apiKey": "${OPENROUTER_API_KEY}"
}
},
"tools": {
"imageGeneration": {
"enabled": true,
"provider": "openrouter",
"model": "openai/gpt-5.4-image-2"
}
}
}
Tip
Prefer environment variables like
${OPENROUTER_API_KEY}instead of pasting raw API keys intoconfig.json.
Using Image Generation in Chat
- Describe the image you want—include aspect ratio or size if you want something other than the default.
- Attach a reference image when you want to edit an existing picture (with a provider/model that supports editing).
- Ask for follow-up tweaks in the same chat—such as "make it warmer", "change the background", or "try a 16:9 version"—and nanobot will build on the previous image automatically.
Generated images are saved locally under ~/.nanobot/media/generated/YYYY-MM-DD/.
Configuration Reference
| Option | Default | Description |
|---|---|---|
tools.imageGeneration.enabled |
false |
Enable or disable image generation |
tools.imageGeneration.provider |
"openrouter" |
Provider name (openrouter, openai, openai_codex, custom, aihubmix, minimax, gemini, ollama, stepfun, zhipu, modelscope, or a named custom connection) |
tools.imageGeneration.model |
"openai/gpt-5.4-image-2" |
Image model ID |
tools.imageGeneration.defaultAspectRatio |
"1:1" |
Default aspect ratio when not specified in chat |
tools.imageGeneration.defaultImageSize |
"1K" |
Default size hint (e.g. 1K, 2K, 4K, or 1024x1024) |
tools.imageGeneration.maxImagesPerTurn |
4 |
Maximum images per request (1–8) |
tools.imageGeneration.saveDir |
"generated" |
Subfolder inside nanobot's media directory for saved images |
Custom connections and advanced options
You can reuse any custom connection created in Settings → Models → Manage providers as long as its endpoint supports the OpenAI Images API (/images/generations).
For image-only request differences (such as provider-specific quality or watermark parameters), use Advanced options → Headers / Body parameters in Image generation settings (or tools.imageGeneration.extraHeaders and extraBody in JSON). Switching image providers in the WebUI clears those overrides automatically so settings do not leak to another service.
Provider Notes
For all providers below, configure the connection in Settings → Models and select it under Settings → Capabilities → Image generation. Expand Manual configuration if you edit config.json directly.
OpenRouter
Use any OpenRouter model that supports image output (and image editing if you want reference-image edits).
Manual configuration
{
"tools": {
"imageGeneration": {
"enabled": true,
"provider": "openrouter",
"model": "openai/gpt-5.4-image-2"
}
}
}
OpenAI Codex
Sign in with nanobot provider login openai-codex, then choose OpenAI Codex and gpt-image-2 in image settings. Supports both generation and reference-image edits using your Codex subscription.
Manual configuration
{
"tools": {
"imageGeneration": {
"enabled": true,
"provider": "openai_codex",
"model": "gpt-image-2"
}
}
}
Custom (OpenAI-compatible)
Works with services implementing POST /v1/images/generations (returning b64_json or url). Requires apiBase; apiKey is optional for local servers. Reference-image edits are not supported by the generic custom provider.
Manual configuration
{
"providers": {
"custom": {
"apiKey": "${CUSTOM_IMAGE_API_KEY}",
"apiBase": "https://api.example.com/v1"
}
},
"tools": {
"imageGeneration": {
"enabled": true,
"provider": "custom",
"model": "your-model-name"
}
}
}
Use extraBody for provider-specific options—for example, "response_format": "url" (Agnes AI), "response_format": "base64" (Together AI), or explicit size values (Volcengine Ark Seedream).
AIHubMix
Supports gpt-image-2-free. Optional extraBody: {"quality": "low"} can make free generations faster and less likely to time out.
Manual configuration
{
"providers": {
"aihubmix": {
"apiKey": "${AIHUBMIX_API_KEY}",
"extraBody": {
"quality": "low"
}
}
},
"tools": {
"imageGeneration": {
"enabled": true,
"provider": "aihubmix",
"model": "gpt-image-2-free"
}
}
}
MiniMax
Supports text-to-image and editing (up to 16 reference images) with MiniMax-H3-Image and MiniMax-H3-Image-Highspeed, plus legacy image-01. Accepts 1K, 2K, 4K, or explicit dimensions like 2720x1536. See MiniMax's image docs for size limits and pricing. Note that a timed-out H3 request may still complete and be billed.
Manual configuration
{
"providers": {
"minimax": {
"apiKey": "${MINIMAX_API_KEY}"
}
},
"tools": {
"imageGeneration": {
"enabled": true,
"provider": "minimax",
"model": "MiniMax-H3-Image",
"defaultAspectRatio": "1:1"
}
}
}
Gemini
Supports gemini-2.5-flash-image (supports reference-image edits) and imagen-4.0-generate-001 (text-to-image only; supports 1:1, 9:16, 16:9, 3:4, 4:3). Sizing is controlled by defaultAspectRatio (defaultImageSize is ignored).
Manual configuration
{
"providers": {
"gemini": {
"apiKey": "${GEMINI_API_KEY}"
}
},
"tools": {
"imageGeneration": {
"enabled": true,
"provider": "gemini",
"model": "gemini-2.5-flash-image"
}
}
}
Ollama
Works with local Ollama (http://localhost:11434/api, no API key needed) and hosted https://ollama.com/api (requires API key). Reference images are not supported.
Manual configuration
{
"providers": {
"ollama": {
"apiBase": "http://localhost:11434/api"
}
},
"tools": {
"imageGeneration": {
"enabled": true,
"provider": "ollama",
"model": "x/z-image-turbo",
"defaultAspectRatio": "16:9",
"defaultImageSize": "2K"
}
}
}
StepFun
Supports step-image-edit-2 (text-to-image) and step-1x-medium (adds style-reference edits). Shares providers.stepfun.apiKey with StepFun chat models. For StepPlan subscriptions, set apiBase to https://api.stepfun.ai/step_plan/v1.
Manual configuration
{
"providers": {
"stepfun": {
"apiKey": "${STEPFUN_API_KEY}"
}
},
"tools": {
"imageGeneration": {
"enabled": true,
"provider": "stepfun",
"model": "step-image-edit-2"
}
}
}
Zhipu
Supports glm-image, cogview-4, cogview-4-250304, and cogview-3-flash (text-to-image only). Supported aspect ratios: 1:1, 16:9, 9:16, 3:4, 4:3, or explicit WIDTHxHEIGHT.
Manual configuration
{
"providers": {
"zhipu": {
"apiKey": "${ZAI_API_KEY}"
}
},
"tools": {
"imageGeneration": {
"enabled": true,
"provider": "zhipu",
"model": "glm-image"
}
}
}
ModelScope
Supports text-to-image and image editing (e.g. Qwen/Qwen-Image-2512). Supported aspect ratios: 1:1, 16:9, 9:16, 3:4, 4:3, or explicit WIDTHxHEIGHT.
Manual configuration
{
"providers": {
"modelscope": {
"apiKey": "${MODELSCOPE_API_KEY}"
}
},
"tools": {
"imageGeneration": {
"enabled": true,
"provider": "modelscope",
"model": "Qwen/Qwen-Image-2512"
}
}
}
Prompting Tips
For better results, include the subject, composition, style/mood/lighting, any exact quoted text, and what should stay unchanged when editing:
A minimal app icon for nanobot: friendly robot head, rounded square, soft blue and white palette, clean vector style, no text
Use the reference image. Keep the same robot and composition, change the palette to warm orange, and add a subtle sunrise background.
Troubleshooting
| Symptom | Fix |
|---|---|
| Image generation is unavailable | Enable it in Settings → Capabilities → Image generation and save (restart the gateway after manual JSON edits) |
| Missing API key | Configure the provider's API key; if using ${VAR_NAME}, confirm the variable is set before starting nanobot |
| Unsupported image provider | Use one of the supported providers listed above or a saved custom connection |
| Generation times out | Try a smaller size, set extraBody.quality: "low" on AIHubMix, or retry later |
| Reference image rejected | Confirm the file is a valid image inside your workspace or nanobot media directory |