openrouter
Generate images and extract colours using OpenRouter's multi-model API.
Description
The openrouter plugin accesses various image generation models through OpenRouter, providing:
- Access to multiple AI image generation models through a single API
- Automatic model selection (cheapest or free model with image output support)
- Image generation with colour extraction
Requirements
- OpenRouter API key from openrouter.ai/keys
- Set
OPENROUTER_API_KEYenvironment variable
Usage
export OPENROUTER_API_KEY="your-api-key"
tinct generate -i openrouter --ai.prompt "<description>" [flags]
Storing your API key
Rather than pasting your key into every shell session, retrieve it from a secret manager:
# GNOME Keyring / libsecret
export OPENROUTER_API_KEY=$(secret-tool lookup service openrouter)
# Bitwarden CLI
export OPENROUTER_API_KEY=$(bw get password openrouter)
# pass (password-store)
export OPENROUTER_API_KEY=$(pass show openrouter)
Flags
AI flags (shared with google-genai)
| Flag | Default | Description |
|---|---|---|
--ai.prompt | Image description prompt (required) | |
--ai.model | auto | AI model to use (auto-selects cheapest image-capable model) |
--ai.list-models | false | List available models with live pricing and exit |
--ai.no-extended-prompt | false | Disable automatic wallpaper prompt enhancement |
--ai.no-negative-prompt | false | Disable default negative prompt |
--ai.negative-prompt | Custom negative prompt to discourage certain elements |
Plugin-specific flags
| Flag | Default | Description |
|---|---|---|
--openrouter.prefer-free | true | Prefer free models when using auto selection |
Common flags
| Flag | Default | Description |
|---|---|---|
--aspect-ratio | 16:9 | Image aspect ratio (1:1, 3:4, 4:3, 9:16, 16:9, 21:9) |
--count | 32 | Number of colours to extract |
--seed-mode | content | Seed mode: content, manual, random |
Examples
Basic generation
export OPENROUTER_API_KEY="your-api-key"
# Auto-selects cheapest image-capable model
tinct generate -i openrouter \
--ai.prompt "cyberpunk city at night with neon lights" \
-o all
With specific model
tinct generate -i openrouter \
--ai.prompt "watercolor painting of a mountain lake" \
--ai.model "google/gemini-2.5-flash-image-preview" \
--aspect-ratio "16:9" \
-o all
With negative prompt
tinct generate -i openrouter \
--ai.prompt "serene japanese garden" \
--ai.negative-prompt "people, text, watermark" \
-o all
List available models
tinct generate -i openrouter --ai.list-models
Dry run
tinct generate -i openrouter \
--ai.prompt "autumn forest" \
--dry-run -o kitty
Model selection
When --ai.model is auto (the default), tinct:
- Fetches the full model list from the OpenRouter API
- Filters to models with image output capability
- Sorts by cost (cheapest first)
- If
--openrouter.prefer-freeis true (default), selects a free model if available
To see what models are available with current pricing, use --ai.list-models.
How it works
- Request: Send prompt to OpenRouter API
- Model routing: OpenRouter routes to selected model
- Generation: Image generated by chosen model
- Response: Base64 image returned
- Caching: Image cached locally
- Extraction: K-means colour extraction
- Wallpaper: Image provided to output plugins
Generated image location
Images are cached in:
~/.cache/tinct/generated/openrouter/
Negative prompts
Use negative prompts to exclude unwanted elements:
# Avoid certain styles
--ai.negative-prompt "cartoon, anime, illustration"
# Avoid artifacts
--ai.negative-prompt "blurry, low quality, distorted"
# Avoid elements
--ai.negative-prompt "text, watermark, people"
API credits
OpenRouter uses a credit system. Different models have different costs. Monitor usage at OpenRouter dashboard.
Troubleshooting
API key issues
- Verify key at openrouter.ai
- Check OPENROUTER_API_KEY is exported
- Ensure sufficient credits
Model not available
- Use
--ai.list-modelsto see currently available models - Check model name spelling (use full model ID, e.g.
google/gemini-2.5-flash-image-preview) - Try a different model or use
auto
Poor results
- Adjust prompt for the model
- Try different model
- Use negative prompts
See also
- google-genai - Google Gemini generation
- image - Extract from existing images