openrouter-image-gen

Generate images from text prompts via OpenRouter's chat completions API with image modality.

Updated May 29, 2026
One-click install
npx skills add https://github.com/Thedougler/shattered-sea-wiki --skill openrouter-image-gen-thedougler
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: openrouter-image-gen
Source: https://github.com/Thedougler/shattered-sea-wiki/tree/main/.claude/skills/openrouter-image-gen
Command: npx skills add https://github.com/Thedougler/shattered-sea-wiki --skill openrouter-image-gen-thedougler

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Creating custom artwork, character portraits, maps, and scene illustrations normally requires design skills or expensive tools. This Skill lets you generate images directly from text descriptions through OpenRouter's image-capable models, with a single bundled Python script that has no external dependencies. ## Core Features & Use Cases - Text-to-Image Generation: Call OpenRouter's chat completions API with image modality using models like Gemini Flash Image, GPT-5 Image, Flux, Recraft, and Seedream. - Configurable Output: Control aspect ratio (1:1, 16:9, 4:3), resolution (0.5K to 4K), model selection, and output path via CLI flags or environment variables. - Prompting Guidance: A bundled reference covers prompt structure, style keywords, lighting, composition, and TTRPG-specific tips for portraits, battle scenes, maps, and items. - Use Case: A game master needs a portrait of an NPC before tonight's session. They describe the character, run the script with a 9:16 aspect ratio, and receive a saved image file ready to share. ## Quick Start Ask the AI to generate an image of your subject, for example: generate an image of a scarred half-orc berserker with a braided beard in oil painting style.

Frequently Asked Questions about openrouter-image-gen

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I generate an image from a text prompt with OpenRouter?▼

Run the bundled generate-image.py script with your prompt as an argument, for example: python3 generate-image.py "a dragon on a lighthouse". The script calls OpenRouter's chat completions API with image modality, saves the image, and prints the absolute file path.

What image generation models are available on OpenRouter?▼

Available models include google/gemini-2.5-flash-image (the default), openai/gpt-5-image and gpt-5-image-mini, black-forest-labs/flux.2-pro and flux.2-max, recraft/recraft-v4.1, x-ai/grok-imagine-image-quality, and bytedance-seed/seedream-4.5. Query the live list via the OpenRouter models API filtered by image output modality.

How do I set the OpenRouter API key for image generation?▼

Add OPENROUTER_API_KEY=sk-or-v1-your-key to a .env file in your project directory or home directory. The script loads it automatically at runtime. You can also set OPENROUTER_IMAGE_MODEL, OPENROUTER_IMAGE_ASPECT, and OPENROUTER_IMAGE_SIZE as defaults.

Can I control the aspect ratio and resolution of generated images?▼

Yes. Use the --aspect flag for ratios like 1:1, 16:9, or 4:3, and --image-size for resolutions of 0.5K, 1K, 2K, or 4K. These are passed to the API as image_config parameters, though support depends on the selected model.

Why does image generation fail with a 400 or 402 API error?▼

A 400 error means the prompt was rejected or the model does not support image output, so try a different model. A 402 error means insufficient OpenRouter credits, which requires topping up your account balance at openrouter.ai.

Which AI image models render text in images well?▼

Flux models (flux.2-pro and flux.2-max) handle text rendering reasonably well, while most other models render text poorly. For other models, generate the image clean and composite text afterward using an image editor.