What you’re building

FLUX 3 Image, 2736×1536, saved to assets/hero.png 55 seconds after one request typed into Claude Code.
list-models lets Claude look up image models, their benchmark scores, and the inputs they accept. generate-image calls any image model on OpenRouter and bills your OpenRouter account. You type requests in plain English, and Claude calls the tools, saves the file, and updates your code.
By the end, you will have:
- Connected the OpenRouter MCP server to Claude Code.
- Generated an image from a plain-English request and added it to a page in your project.
- Changed part of that image while keeping the rest of the scene.
- Asked Claude to compare image models on OpenRouter for a specific job.
Before you start
- Claude Code installed on your machine.
- An OpenRouter account with credits. The walkthrough uses FLUX 3 Image (
black-forest-labs/flux-3-image); see its model page for pricing, or browse all image models and the image generation guide. - A project folder where you want images saved. This guide uses an example folder containing
index.htmlfor a bookshop called Fox & Lantern Books with a placeholder comment<!-- hero image goes here: assets/hero.png -->. Use your own project folder and file paths when you run the steps. - For full details on the server, see the OpenRouter MCP server documentation.
Step 1: Connect the OpenRouter MCP
From the same project directory you plan to open in Step 2, add the OpenRouter MCP server to Claude Code and sign in through your browser (Claude Code’s default local scope registers the server for the current directory, or pass--scope user to make it available across projects):
/mcp, selecting openrouter, and choosing Authenticate. You can disconnect anytime.
Browser sign-in (OAuth) is recommended. If you prefer to use an existing OpenRouter API key instead, pass it as an authorization header (note that your shell expands $OPENROUTER_API_KEY into the command’s arguments, which can be visible to other local processes on a shared machine):
claude mcp list:
Step 2: Ask for an image
Open Claude Code in your project folder and ask for the image you need, where to save it, and which file to update. Adapt the file paths and description to your own project:black-forest-labs/flux-3-image, writes a longer prompt, and chooses a 16:9 aspect ratio for a hero image. The generate-image tool returns a link to the image that is valid for 24 hours:
assets/hero.png, edits index.html, and opens the saved file to check it against your request. The whole request takes 55 seconds, and Claude replies:
Step 3: Change the image
In the same session, ask Claude to change specific parts of the image and overwrite the file:reference_image_urls and refers to it as “image 1” in the prompt:
reference_image_urls parameter accepts up to 16 https or data URLs and works on models that accept image input. The signed link from Step 2 lasts 24 hours, so this works within that time. If Step 2 returned an inline image instead of a link (or after the link expires), pass a data: URL from the saved assets/hero.png file or host the image at an https URL and give that to Claude. If neither is available, stop rather than letting Claude generate a fresh image without the reference.
Claude downloads the edited image to a temporary file, opens it to check it, and replaces assets/hero.png. This takes 82 seconds:

The same image after one follow-up request. The fox has a red scarf and the book is red. The rest of the scene is unchanged.
Step 4: Let Claude choose the model
You can ask Claude to compare models for a job before it generates anything. Looking up models is not billed. Generating an image is.list-models twice with output_modalities: image, once sorted by design-arena-elo-high-to-low and once sorted by top-weekly, without calling generate-image. In 19 seconds it recommends one model:
How the image reaches your project
Thegenerate-image tool returns a link to the image when one can be issued. Otherwise it returns the image itself. The same model can return a link on one request and the image on another, so expect either.
- A link. The link opens without an API key until it expires. Claude Code downloads it into your project with
curl. - The image itself. Claude Code saves it in its own folder, at
~/.claude/projects/<project>/tool-results/mcp-openrouter-blob-<id>.png, and then copies it into your project. Copying out of that folder needs your approval. Without it the copy is refused, and Claude prints amkdir -pandcpcommand you can run yourself.
Troubleshooting
Check your work
claude mcp listshowsopenrouteras Connected.- The image file, such as
assets/hero.png, exists in your project and opens. - Your page, such as
index.html, shows the image in a browser.