API Reference

One API for AI image and video generation. Every model — realism, anime, video — is served by the same endpoints; the media kind and the price come from the model you pick. Two ways to pay:

Credits — prepay with an API key, authenticate with a Bearer header. Predictable, simple.
x402 — pay per call in USDC on Base, no account needed. Your wallet signs an X-PAYMENT header.

Base URL: https://imference.com · Try it live in the Credits or x402 playground.

Working in an agent? The imference-mcp server wraps this entire API for Claude Code, Claude Desktop and Cursor — model cards, generation and payment included. Set it up in one line →

Quickstart — Credits

  1. Buy credits — your API key is created with the first purchase.
  2. POST /generate with your model + prompt (Bearer auth).
  3. Poll GET /status?request_id=… until it returns your media URL.
curl -X POST 'https://imference.com/generate' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{"model": "illustrious-hassuka-xl", "prompt": "A cat astronaut floating in space"}'
# → {"request_id": "abc-123", "kind": "image"}

curl 'https://imference.com/status?request_id=abc-123' \
  -H 'Authorization: Bearer YOUR_API_KEY'
# 404 while running · 422 if failed · 200 with the media URL when done

Quickstart — x402

No account, no key: your wallet pays per call in USDC on Base. The first request answers 402 Payment Required with the price; your x402 client signs an EIP-3009 authorization and retries automatically. Use an x402 client library or try the playground.

import { wrapFetchWithPayment } from "x402-fetch";

const fetchWithPay = wrapFetchWithPayment(fetch, walletClient); // your viem wallet
const res = await fetchWithPay("https://imference.com/ondemand/generate", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ model: "illustrious-hassuka-xl", prompt: "A cat astronaut" }),
});
const { request_id } = await res.json();
// then poll GET /ondemand/status?request_id=… (no auth needed)

Authentication & payment

Credits rail

Every request carries Authorization: Bearer YOUR_API_KEY. The per-model cost in credits (im_cost) is debited at enqueue.

x402 rail

No auth header. Payment is proven by the signed X-PAYMENT header (EIP-3009 USDC authorization). Price is dynamic per model: im_cost credits × $0.001.

POST /generate /ondemand/generate

Generate an image or a video — one endpoint for every model. The media kind and the price come from the model; the response echoes both. Returns a request_id for status polling.

curl -X POST 'https://imference.com/generate' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "illustrious-hassuka-xl",
    "prompt": "A cat astronaut floating in space",
    "width": 1024, "height": 1024,
    "steps": 28, "guidance_scale": 6
  }'
# A bare request returns 402 with the payment requirements (price in USDC).
# Use an x402 client to sign the X-PAYMENT header automatically:
curl -X POST 'https://imference.com/ondemand/generate' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "illustrious-hassuka-xl",
    "prompt": "A cat astronaut floating in space"
  }'

Request body

  • model (required) — model code from GET /api/models
  • prompt (required) — text description
  • every other field depends on the model — see Parameters per model below. Anything you omit falls back to that model's catalog default; anything it doesn't accept is refused with a 400.

Response

{"request_id": "abc-123", "kind": "image"}

kind is "image" or "video" — video generations take minutes; size your polling accordingly.

Parameters per model

Models don't take the same parameters: an SDXL checkpoint has CFG and CLIP-skip, MiniMax-H3 has neither but takes a clip duration, WAN runs at exactly 6 steps. The table below is read live from GET /api/models — the same list the API validates against, so it cannot go out of date. A parameter that isn't listed for a model is refused with a 400.

Loading the catalog…

Video generation

Same endpoint — pick a video model and it generates a video. No img_url → text-to-video; with img_url → image-to-video. The price adjusts to the model automatically.

curl -X POST 'https://imference.com/generate' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "wan22-video",
    "prompt": "A fox running through a snowy forest",
    "num_frames": 81, "fps": 20
  }'
# → {"request_id": "…", "kind": "video"}  — poll /status; expect minutes, not seconds
GET /status?request_id=… /ondemand/status?request_id=…

Check a generation. The polling contract is explicit:

HTTP Meaning What to do
404Still runningKeep polling (1s is fine; videos run minutes)
422Generation failedStop polling — error carries the reason
200DoneDownload data.URL
curl 'https://imference.com/status?request_id=YOUR_REQUEST_ID' \
  -H 'Authorization: Bearer YOUR_API_KEY'
curl 'https://imference.com/ondemand/status?request_id=YOUR_REQUEST_ID'
# no auth needed — the request_id is the capability
GET /media/all Credits rail only

All media (images and videos) generated with your API key, newest first. Each row carries a Kind field.

curl 'https://imference.com/media/all' \
  -H 'Authorization: Bearer YOUR_API_KEY'
GET /credits/balance Credits rail only

Your remaining credit balance.

curl 'https://imference.com/credits/balance' \
  -H 'Authorization: Bearer YOUR_API_KEY'
# → {"credits": 1250}
POST /ondemand/credits/add x402 payment

Prepay API-key credits with one on-chain USDC payment — the x402 price is exactly credits × $0.001. Saves the per-call network fee when you generate a lot. Min 100, max 1,000,000 credits per call. An empty api_key creates a fresh key and returns it. Or use the pricing page UI.

const res = await fetchWithPay("https://imference.com/ondemand/credits/add", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ credits: 5000, api_key: "" }), // "" → new key
});
// → {"api_key": "…", "credits_added": 5000}

Models & formats

Public, no auth. GET /api/models lists every model with its defaults, the parameters it accepts (parameters, see below) and its base cost. GET /api/formats lists each model's supported resolutions, so you never hardcode sizes.

A run costs ceil(im_cost × credit_multiplier × duration_multiplier × batch_nbr) credits, with a floor of 1 (1 credit = $0.001; the x402 price is the same amount in USDC). credit_multiplier comes from the chosen format (an HD format typically bills ×2) and duration_multiplier is the requested clip length over the model's default duration — so a 10 s clip on a model defaulting to 5 s costs twice as much. The rounding is applied once, to the whole product.

curl 'https://imference.com/api/models'
curl 'https://imference.com/api/formats'

Errors

Standard HTTP codes; error bodies are {"error": "…"}.

Status Meaning Common cause
400Bad requestMissing/invalid fields, insufficient credits
401UnauthorizedMissing or unknown API key (credits rail)
402Payment requiredx402: no valid payment — the body lists the requirements to sign
404Not foundUnknown model/endpoint/request_id — or generation still running (keep polling)
422Generation failedWorker error — stop polling, the reason is in error
429Too many requestsRate limit exceeded (50 req/min)
500Server errorRetry, or contact support

Rate limits & terms

50 requests per minute per API key (credits) or wallet address (x402). Exceeding it returns 429.

See the Terms of Service.