OpenRouter image generation plugin for Hermes Agent — Gemini image models via chat completions with multi-image merge/edit/compose support
- Python 99.7%
- Shell 0.3%
- Update generate() to accept image_url + reference_image_urls (new ABC) - Add capabilities() declaring text+image modalities, max 9 reference images - Use normalize_reference_images() helper from upstream - Replace prompt size hints with native image_config.aspect_ratio parameter - Add modalities: ['image', 'text'] to API payload - Add models: Nano Banana Pro, Flash/Stable variants, Grok Imagine, Seedream 4.5, FLUX.2 Pro, GPT-5 Image Mini (8 total, was 1) - Handle snake_case + camelCase response formats - Extract _prepare_image_content_parts and _save_image helpers - Maintain backward compat with legacy images= kwarg - Bump timeout to 180s for larger image models - Update README with model table, new API usage, upstream compat notes |
||
|---|---|---|
| patches | ||
| plugin | ||
| .gitignore | ||
| __init__.py | ||
| fix-data-perms.sh | ||
| plugin.yaml | ||
| README.md | ||
hermes-openrouter-image-gen
OpenRouter image generation plugin for Hermes Agent.
What it does
Adds OpenRouter as an image generation backend via /v1/chat/completions — for image models (Gemini, GPT Image, Grok, FLUX, Seedream) that return images inline in chat responses.
Features:
- Text-to-image via 8 models (Gemini Flash/Pro, GPT-5 Image Mini, Grok Imagine, Seedream 4.5, FLUX.2 Pro)
- Multi-image input for merge/edit/compose via
image_url+reference_image_urls - Image-to-image editing (primary source + reference images)
- Native aspect ratio control via
image_configAPI parameter - Safety settings:
BLOCK_NONEfor all 4 categories - Data URI + URL + local file path input handling
- Response parsing: handles snake_case, camelCase, content parts, bare URLs, raw base64
Models
| Model | Speed | Price | Best For |
|---|---|---|---|
| Nano Banana 2 (Flash) | ~3-8s | ~$0.07 | Fast, good quality |
| Nano Banana 2 (Flash) Stable | ~3-8s | ~$0.07 | Same, stable endpoint |
| Nano Banana Pro | ~8-15s | ~$0.15 | Best quality, 2K/4K |
| Nano Banana Pro Stable | ~8-15s | ~$0.15 | Same, stable endpoint |
| Grok Imagine | ~5-10s | ~$0.012/K | Photorealism, text |
| Seedream 4.5 | ~5-10s | $0.04 flat | Editing, portraits |
| FLUX.2 Pro | ~6s | ~$0.03/MP | Studio quality |
| GPT-5 Image Mini | ~10-15s | ~$0.008 | Cheapest option |
Installation
# Clone
git clone https://git.ashu.io/ashuio/hermes-openrouter-image-gen.git /tmp/or-img
# Deploy plugin
mkdir -p ~/.hermes/plugins/image_gen/openrouter
cp /tmp/or-img/plugin/* ~/.hermes/plugins/image_gen/openrouter/
# Enable
hermes config set image_gen.provider openrouter
hermes config set image_gen.model google/gemini-3.1-flash-image-preview
Docker deployment
FROM nousresearch/hermes-agent:latest
# Clone plugin
RUN git clone --depth 1 https://git.ashu.io/ashuio/hermes-openrouter-image-gen.git /tmp/or-img && \
mkdir -p /opt/data/plugins/image_gen/openrouter && \
cp /tmp/or-img/plugin/* /opt/data/plugins/image_gen/openrouter/ && \
rm -rf /tmp/or-img
Config
image_gen:
provider: openrouter
model: google/gemini-3.1-flash-image-preview
openrouter:
model: google/gemini-3.1-flash-image-preview
plugins:
enabled:
- image_gen/openrouter
Multi-image usage
# Text-to-image
image_generate(prompt="a sunset over mountains", aspect_ratio="landscape")
# Image editing (new ABC contract)
image_generate(
prompt="make this a watercolor painting",
image_url="/path/to/photo.jpg",
)
# Multi-image merge (new ABC contract)
image_generate(
prompt="swap the legs between these two women",
image_url="/path/to/image1.jpg",
reference_image_urls=["/path/to/image2.jpg"],
)
# Legacy format (still supported)
image_generate(
prompt="merge these images",
images=["/path/to/image1.jpg", "/path/to/image2.jpg"],
)
Upstream compatibility
v2.0 (current): Matches the upstream ImageGenProvider ABC contract:
generate()acceptsimage_urlandreference_image_urlsas keyword-only paramscapabilities()declaresmodalities: ["text", "image"]andmax_reference_images: 9- Uses
normalize_reference_images()helper - Uses
image_configfor native aspect ratio control (replaces prompt injection) - Uses
modalities: ["image", "text"]in API payload - Handles both snake_case and camelCase response formats
No upstream tool patch required. The upstream image_generation_tool.py already passes images= to the plugin dispatch. The patches/ directory is retained for legacy Hermes versions only.
Cost
~$0.07/image for Gemini 3.1 Flash, ~$0.15/image for Gemini Pro, $0.04 flat for Seedream.