Docs

Generate and edit images with the best AI models over a simple HTTP API. Generation is asynchronous: submit a request, poll until it’s done, then fetch the image.

Authentication

All requests require an API key. Create one in Settings → API Keys and send it as a bearer token (or an x-api-key header). Credits are the spend cap — each image costs credits by model and resolution.

Authorization: Bearer <your-api-key>
# or
x-api-key: <your-api-key>

Base URL: https://modelmux.dev

Generate an image

POST/api/v1/generations

Enqueues a generation and returns immediately with status: "pending" and an historyId. Credits are charged when the job runs and refunded automatically if it fails. The request body is selected by Content-Type.

Send application/json. Fields: prompt (required), model, resolution, aspectRatio.

curl -X POST https://modelmux.dev/api/v1/generations \
  -H 'Authorization: Bearer <your-api-key>' \
  -H 'Content-Type: application/json' \
  -d '{
    "prompt": "a red fox in fresh snow, golden hour",
    "model": "nano-banana-pro",
    "resolution": "2k",
    "aspectRatio": "16:9"
  }'

Response (202-style, pending)

{
  "historyId": "V1StGXR8_Z5jdHi6B-myT",
  "status": "pending",
  "model": "nano-banana-pro",
  "aspectRatio": "16:9",
  "resolution": "2k",
  "creditsCharged": 13,
  "provider": "kie",
  "createdAt": 1733011200000
}

Poll status

GET/api/v1/generations/:id

Poll with the historyId every few seconds until status is completed (or failed). Most images finish in seconds; large/4K jobs take longer.

curl https://modelmux.dev/api/v1/generations/V1StGXR8_Z5jdHi6B-myT \
  -H 'Authorization: Bearer <your-api-key>'
{
  "historyId": "V1StGXR8_Z5jdHi6B-myT",
  "status": "completed",
  "provider": "kie",
  "outputUrl": "/api/storage/file?key=generated/…",
  "creditsUsed": 13,
  "model": "nano-banana-pro",
  "resolution": "2k",
  "aspectRatio": "16:9",
  "completedAt": 1733011230000
}

Statuses: pendingprocessing completed | failed (with errorMessage).

Fetch the image

GET/api/v1/generations/:id/image

Once completed, stream the raw image bytes (key-authenticated). Save it to a file or pipe it onward.

curl https://modelmux.dev/api/v1/generations/V1StGXR8_Z5jdHi6B-myT/image \
  -H 'Authorization: Bearer <your-api-key>' \
  -o output.png

Models & pricing

Cost is charged in credits, by model and resolution. Pass the model id below; credits line up with the resolutions in the same order.

Model idResolutionsCredits
nano-banana1K4
nano-banana-2-lite1K3
nano-banana-21K · 2K · 4K7 · 10 · 14
nano-banana-pro1K · 2K · 4K13 · 13 · 22
gpt-image-21K · 2K · 4K8 · 12 · 18

For how to choose between models, see Models.

Parameters

FieldValuesDefault
promptstring, 5–2000 charactersrequired
modelnano-banana | nano-banana-2-lite | nano-banana-2 | nano-banana-pro | gpt-image-2nano-banana-2-lite
resolution1k | 2k | 4k — must be supported by the model1k
aspectRatio1:1 | 2:3 | 3:2 | 3:4 | 4:3 | 9:16 | 16:91:1

Passing a resolution the model does not support returns 400. Check the table above, or fetch the catalog programmatically.

Discover models programmatically

Agents and clients can read the full catalog — ids, resolutions, aspect ratios, credit costs and defaults — from one unauthenticated endpoint. Prefer this over hardcoding model ids.

GET/api/v1/models
curl https://modelmux.dev/api/v1/models

Errors & status codes

Errors are JSON: { "error": string, "code": string }.

StatusMeaning
200Success
400Bad input (invalid body, unsupported model/resolution)
401Missing or invalid API key
404Generation not found / image not ready
413Reference image too large
415Unsupported reference file type (must be an image)
429Rate limit exceeded
500Unexpected server error

If a generation failed, the credit is refunded automatically — check errorMessage on the status response.

MCP server

Use ModelMux from any MCP client (Claude Desktop, Cursor, …) via the modelmux-mcp server — it generates an image, polls until ready, and returns it.

{
  "mcpServers": {
    "modelmux": {
      "command": "npx",
      "args": ["-y", "modelmux-mcp"],
      "env": { "MODELMUX_API_KEY": "<your-api-key>" }
    }
  }
}

Agent skill (Claude Code)

Install the modelmux skill to generate and edit images from Claude Code (and other agents) with bundled recipes.

# project scope → .claude/skills/modelmux/
npx skills add modelmux/skills -a claude-code

# or global → ~/.claude/skills/modelmux/
npx skills add modelmux/skills -a claude-code -g

Export MODELMUX_API_KEY where the agent runs, then ask it to “generate an image of …”.

Ready to start?

New accounts get free credits to try every model.

Create your API key