openrouter-image-gen-mcp
Generates images using Google Gemini models (e.g., Gemini 2.5 Flash Image Preview) via the OpenRouter API, with support for saving images locally and flexible output options.
Click on "Deploy Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@openrouter-image-gen-mcp Generate an image of a futuristic city skyline at night"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
OpenRouter Image Generation MCP Server
An MCP (Model Context Protocol) server that provides image generation capabilities through the OpenRouter API, supporting models like Gemini 2.5 Flash Image Preview.
Features
Image Generation: Generate images using Google Gemini 2.5 Flash Image Preview
Flexible Options:
Save generated images to local files
Related MCP server: jgkme/kilo-image-gen-mcp
Installation
Clone the repository:
git clone https://github.com/a13.team/openrouter-image-gen-mcp.git
cd openrouter-image-gen-mcpInstall dependencies:
npm installBuild the TypeScript code:
npm run buildSet up your OpenRouter API key:
export OPENROUTER_API_KEY="your-api-key-here"You can get an API key from OpenRouter.
Configuration for Claude Desktop
Add the following to your Claude Desktop configuration file:
macOS/Linux
Location: ~/.config/claude/claude_desktop_config.json
Windows
Location: %APPDATA%\Claude\claude_desktop_config.json
Cursor IDE Configuration
Location: ./cursor/mcp.json
{
"mcpServers": {
"openrouter-image-gen": {
"command": "node",
"args": ["/path/to/openrouter-image-gen-mcp/dist/index.js"],
"env": {
"OPENROUTER_API_KEY": "your-api-key-here"
}
}
}
}Replace /path/to/openrouter-image-gen-mcp with the actual path to your installation directory.
Available Tools
1. generate_image
Generate images using AI models.
Parameters:
prompt(required): Text description of the image to generatemodel: Model to use (default:google/gemini-2.5-flash-image-preview)n: Number of images to generate (1-4, default: 1)size: Image dimensions (default:1024x1024)save_to_file: Save images locally (default: false)filename: Base filename for saved imagesshow_full_response: Include full base64 data in response (default: false, returns concise info only)
Example:
{
"prompt": "A serene Japanese garden with cherry blossoms",
"model": "google/gemini-2.5-flash-image-preview",
"save_to_file": true,
"filename": "japanese_garden"
}Note: Gemini image generation works through the chat completions API. The model will generate an image based on your prompt and return it as a URL or base64 data in the response. The size parameter is not used for Gemini models.
2. list_models
List all available image generation models.
Development
Build
npm run buildRun in development mode
npm run devStart the server
npm startAPI Documentation
Troubleshooting
401 Authentication Error
If you get a 401 error, check:
Your API key is correctly set in the environment or Claude Desktop config
The API key starts with
sk-or-(OpenRouter format)The API key is valid and has not expired
You have credits available in your OpenRouter account
Test your API key loading:
node test-api-key.jsCommon Issues
API Key not loading: Make sure the
OPENROUTER_API_KEYis set in your Claude Desktop config'senvsectionModel access denied: Some models require specific permissions or higher tier accounts
Image not generating for Gemini: Gemini uses the chat completions endpoint, not the images endpoint
License
WTFPL - Do What The Fuck You Want To Public License
Contributing
Contributions are welcome! Please feel free to submit a Pull Request.
Else Models:
`google/gemini-3-pro-image-preview`
`google/gemini-2.5-flash-image`
`google/gemini-2.5-flash-image-preview`Available Tools
2 toolsgenerate_imageA
Generate images using Google Gemini API. Control image style, aspect ratio, and composition through descriptive text in your prompt.
Inputs: prompt (required), filename, save_to_file, show_full_response.
list_modelsB
Show information about the Gemini image generation model
Inputs: no named parameters.
Tool Schema Changelog
Recent tool additions, removals, and schema changes observed during successful MCP inspections.
Loading tool schema changelog…
TDQS
Scored across 2 tools
generate_image and list_models serve clearly different purposes: one creates an image, the other retrieves model metadata. There is no overlap or ambiguity between the two tools.
Both tool names follow the same verb_noun pattern using snake_case, making the naming predictable and consistent across the set.
Two tools is on the thin side for an image generation server, but the pair covers the essential generation action and a supporting model lookup. It feels minimal yet not unreasonable.
The core image generation workflow is covered by generate_image, and list_models provides useful context for model selection. Minor gaps exist, such as no ability to inspect generation parameters or retrieve past generations, but these are not critical for a simple image generation API.
Maintenance
Related MCP Connectors
MCP server for Qwen Image 3 AI image generation
Focused MCP server for OpenAI image/audio generation (v2.0.0). Wraps endpoints via HAPI CLI.
MCP server for Flux AI image generation
MCP server for OpenAI API (chat completions, image generation, embeddings) via AceDataCloud
Related MCP Servers
- FlicenseAqualityDmaintenanceMCP server that generates images using Gemini models via an OpenAI-compatible gateway.19-
- AlicenseNot gradedqualityCmaintenanceMCP server for generating, editing, and processing images via multiple providers including Kilo, OpenRouter, OpenAI, and Gemini, with local tools for background removal, resizing, and cropping.16 npm3MIT
- AlicenseAqualityDmaintenanceMCP server for AI image generation supporting multiple providers (OpenRouter, Together AI, Replicate, fal.ai) and compatible with various MCP agents.283 npm1MIT
- AlicenseAqualityDmaintenanceMCP server for AI image generation supporting text-to-image and image-to-image editing via any OpenAI-compatible service, with configurable models, aspect ratios, and sizes.2MIT