AI image generation API your agent can call on its own.
One prompt in, a hosted image URL out. Image MCP Server exposes the same operation as a REST endpoint for your backend and as an MCP tool for Claude, Cursor and every other agent — so the picture your assistant needs mid-conversation never has to become a ticket for a human.
Unless you name a model, calls run on google/gemini-2.5-flash-image, Google’s model better known as Nano Banana, at 15 credits a generation. Every other live model, with its credit cost, is in the model list.
- 6
- aspect ratios
- 2
- ways to call it
- 15
- credits on the default model
curl -X POST "https://api.imagemcpserver.com/v1/generate" \
-H "Authorization: Bearer $IMAGEMCP_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"prompt": "A cutaway illustration of a mechanical keyboard switch, technical line art, flat vector, warm cream background, no text",
"aspectRatio": "16:9"
}'{
"success": true,
"deductedCredits": 15,
"userCredits": 985,
"result": {
"imageUrl": "https://cdn.imagemcpserver.com/gen/8f2c.png",
"model": "google/gemini-2.5-flash-image",
"aspectRatio": "16:9",
"seed": 481923,
"latency": "4.21s",
"hasInputImage": false
}
}Actual output
Real generate_image output, unedited
Four unedited calls through this API: the prompt that was sent, and the model, seed and latency each response reported. All four ran on gemini-2.5-flash-image, the default model, which costs 15 credits a generation. The same four images are in the gallery on the homepage.

Fig. 017.04sseed 679263
“A golden valley at sunset, layered mountain ridges receding into warm haze, winding river”
gemini-2.5-flash-image

Fig. 027.89sseed 565146
“A busy cyberpunk cityscape at night, neon-lit skyscrapers, drifting mist, cinematic”
gemini-2.5-flash-image

Fig. 037.01sseed 106312
“Close-up product photograph of a smartwatch displaying a glowing holographic time interface”
gemini-2.5-flash-image

Fig. 047.93sseed 53382
“Overlapping golden circles, arcs and quarter-rounds with crisp black outlines on cream paper”
gemini-2.5-flash-image
To turn calls like these into finished site assets, follow the workflows for landing page images, blog featured images and Open Graph backdrops, or learn to write prompts like these.
Text-to-image and image-to-image, behind the same call
The endpoint decides which mode it is in from what you send. A prompt on its own generates from scratch. Add image and it works from your picture. Add referenceImages and it borrows style from several at once.
Text to image
Prompt only. The model composes the scene from nothing — the mode you want for hero art, illustrations and concept boards.
Image to image
Pass a source image and a prompt describing the change. Useful for restyling a photo, changing a season, or re-rendering a rough sketch.
Reference-guided
Pass two or three examples in referenceImages so a whole batch comes back in one consistent visual language instead of drifting.
Call it from any language
It is one POST with a bearer token, so there is no SDK to install and nothing to keep up to date. Every response carries deductedCredits and userCredits, so a script always knows what it just spent and what is left.
import os, requests
r = requests.post(
"https://api.imagemcpserver.com/v1/generate",
headers={"Authorization": f"Bearer {os.environ['IMAGEMCP_API_KEY']}"},
json={
"prompt": "A paper boat on still dark water, top-down, flat vector, three colours, no text",
"aspectRatio": "16:9",
},
timeout=120,
)
data = r.json()
print(data["result"]["imageUrl"], data["deductedCredits"])const res = await fetch("https://api.imagemcpserver.com/v1/generate", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.IMAGEMCP_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
prompt: "A paper boat on still dark water, top-down, flat vector, three colours, no text",
aspectRatio: "16:9",
}),
});
const { result, deductedCredits } = await res.json();
console.log(result.imageUrl, deductedCredits);You: make a 16:9 hero for the pricing page, flat vector, no text
→ generate_image({ prompt: "...", aspectRatio: "16:9" })
Done — https://cdn.imagemcpserver.com/gen/8f2c.png (15 credits)The same endpoint, reached as the generate_image MCP tool. This is the part most image APIs do not have — connect a client once and the model calls it without you writing the request at all.
Every field, and what it changes
One required field. Everything else has a sane default, so the smallest useful request is a single line of JSON.
Read the endpoint docs →| Field | Accepts | What it does |
|---|---|---|
prompt | string · required | What to draw. Long, specific prompts beat short ones — subject, medium, lighting, framing, palette. |
model | string | A model ID such as google/gemini-2.5-flash-image or black-forest-labs/flux-1.1-pro. Omit it to use the account default. |
aspectRatio | 1:1 · 16:9 · 9:16 · 4:3 · 3:4 · 21:9 | Framing of the output. Defaults to 1:1. |
style | string | Recorded on the request and echoed back as result.style — it is not sent to the model. Put style direction in the prompt itself. |
image | string | A URL or base64 data URI to generate from, turning the call into image-to-image. |
referenceImages | string[] | Several examples that steer style, layout or subject without being copied outright. |
responseFormat | url · b64_json | Defaults to url. b64_json adds the raw base64 to the response. |
Pick the frame before you pick the prompt
Cropping a square down to a banner throws away half the composition the model worked on. Asking for the shape you actually need is free.
Avatars, product tiles, app icons, Instagram posts
Hero images, YouTube thumbnails, slide backgrounds
Stories, Reels, TikTok, mobile splash screens
Blog inline figures, documentation screenshots
Pinterest pins, portrait product shots, book covers
Ultra-wide banners, GitHub social previews, page headers
Three of the use cases lean on this call, with the frame chosen for you: Open Graph backdrops at 16:9, landing page heroes at 21:9 and blog featured images at 16:9.
Your assistant asks for the picture itself
Connect the MCP server once and generate_image shows up in the tool list of whatever client you use. The agent writes the prompt, reads back the hosted URL, and drops it straight into the file it is editing — no copy-paste round trip through a browser tab.
tools/call
{
"name": "generate_image",
"arguments": {
"prompt": "Isometric illustration of a
server rack made of paper, cream
background, soft studio light",
"aspectRatio": "4:3",
"referenceImages": [
"https://example.com/brand-style.png"
]
}
}Endpoint: https://mcp.imagemcpserver.com/mcp
What a generation costs
Fast model
8 credits
Quick drafts, thumbnails, iterating on a prompt.
Default model
15 credits
google/gemini-2.5-flash-image (Nano Banana), where calls land unless you name a model.
Premium model
30 credits
When the image ships to a customer, not a mockup.
Your OpenRouter key
2 credits
BYOK on any monthly plan. OpenRouter bills the model directly.
Checking your balance is free — get_user_info and list_models never deduct credits, so a careful agent can price the work before it starts it. See plans and credit packs, or the full model list with each model’s cost.
The $5 Testing plan gets you 100 credits, once: 6 generations on the default 15-credit model with 10 left for compressions, or 12 on an 8-credit fast model — enough to prove the whole chain works. Cost follows the model rather than the prompt, so iterating on wording is cheap; the BYOK break-even is worked through here.
Workflows that call generate_image
Each of these use cases runs this tool as one step of a larger job, with the tool order and the credit cost worked out.
- AI Open Graph image generationA text-free 16:9 backdrop per section; your framework renders the title over it.
- AI images for landing pagesThe hero, feature art and OG card for one page, all from one reference image.
- Blog featured imagesA featured image for every post, kept on one house style.
- Social media graphicsOne concept rendered natively into each platform’s shape.
Use it from your agent
Connect the server once in Claude Code or Cursor, or in any other MCP client, and generate_image shows up in your agent’s tool list next to the other 7 image tools and 3 utility tools. Setup takes about five minutes. New to the protocol? What MCP is, and how an agent calls a tool.
More image APIs on the same key
One API key and one credit balance cover all eight, over REST or as MCP tools. Six of them return a hosted URL that the next tool accepts as input, so they chain without a download step.
- AI image editing APIEdit or restyle an image from a text instruction8–30 credits
- Background removal APICut the subject out in one call8 credits
- AI image upscaler APICrisp super-resolution in one call15 credits
- Transparent PNG generator APIGenerate and cut out in one call16–38 credits
- AI SVG generator APIGenerate editable vector SVG from a prompt5 credits
- Image compression APIRe-encode smaller with a quality dial1 credit
- Image format converter APIPNG, JPG, WebP, GIF, TIFF, AVIF1 credit
- Compare all eight image APIsCost, response shape and the catch for each, side by side.
AI image generation API questions
What is the difference between the API and the MCP tool?
They are the same operation with two front doors. POST /v1/generate is the HTTP endpoint your own code calls. generate_image is the MCP tool an agent calls after you connect the server once. Both bill the same credits, both write to the same request log, and both return the same response shape.
Which models can I generate with?
Whatever is live on your account at the time of the call. Omit the model field and the request routes to the default, google/gemini-2.5-flash-image — the model usually called Nano Banana — at 15 credits a generation. Call list_models (or GET /v1/models, which is free) to read the current catalogue with each model’s cost, latency and supported aspect ratios; the models page in the docs explains how to read it.
Can I do image-to-image instead of text-to-image?
Yes. Pass image with a URL or base64 data URI to steer generation from a source picture, or pass referenceImages as an array to guide style, layout or subject from several examples at once.
How much does one generation cost?
The cost of the model you routed to: 15 credits on the default, google/gemini-2.5-flash-image, roughly 8 for a fast model and 30 for a premium one. If a model has no recorded cost the server falls back to 15. On a monthly plan with your own OpenRouter key connected, generation costs a flat 2 credits and OpenRouter bills you for the model directly.
Where do the generated images live?
Every result is uploaded to Cloudflare R2 and returned as a hosted https URL. Pass responseFormat: "b64_json" when you would rather receive the raw base64 alongside the URL — useful when the agent has to hand the bytes straight to another tool.