Skip to content

Developers

API reference

Everything to call any model from your code. New here? Start with the API overview.

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, with 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 comes 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.

ParameterTypeDefaultAcceptedNotes
prompt requiredstring··What to generate.
negative_promptstring··What to avoid. Defaults to the model's own negative prompt.
stepsint3015 to 40Denoising steps.
guidance_scalefloat41 to 8Prompt adherence (CFG).
schedulerstring··Sampler. Defaults to euler.
img_urlstring··Source image (https URL or data: URI): the model denoises from it (image-to-image).
strengthfloat0.750.1 to 1img2img strength, with img_url: low keeps the source close, 1 ignores it.
format_codestring·square, portrait, landscape, portrait-large, landscape-large, portrait-wide, landscape-wide, portrait-ultra-wide, landscape-utra-wideOutput format. See /api/formats for each one's resolution and price multiplier.
lorasarray· to 4Up to 4 curated LoRAs: [{code, weight}]. Codes, weight bounds and defaults: GET /api/loras?model=anima-aesthetic. An omitted weight takes the LoRA's default.
seedint··Reproducibility. Omit for a random seed.
batch_nbrint11 to 4Images per request. Each one is billed.

LoRAs

LoRAs are small add-ons that steer a model toward a style, a character, a concept or more detail. Imference serves a curated catalog: each LoRA is reviewed, hosted on our CDN and pre-configured (default strength and its bounds, trigger words). Stack up to 4 on a generation with the loras field. Same price as the generation without them.

curl -X POST 'https://imference.com/generate' \
  -H 'Authorization: Bearer YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
    "model": "cyberrealistic-xl",
    "prompt": "Portrait of a cyborg with gold filigree, soft sidelighting",
    "loras": [{"code": "detail-tweaker-xl", "weight": 1.5}]
  }'

Rules

  • Only models whose parameters list loras take them (SDXL, Pony, Illustrious, Z-Image, Krea 2 and Anima models today).
  • A LoRA goes on a model when the model's model_family_code is in the LoRA's compatible_family_codes (an SDXL LoRA may also fit Pony or Illustrious models).
  • weight is optional: omitted, the LoRA's weight_default applies; otherwise it must sit within [weight_min, weight_max]. Negative weights are valid on LoRAs that allow them (sliders, detail tweakers).
  • If a LoRA lists trigger_words, put them in your prompt. When text_encoder_trained is false they are optional.
  • An unknown, incompatible or out-of-range LoRA is refused with a 400 before anything is charged (x402: before the payment challenge).

Catalog

Public, no auth. GET /api/loras lists every LoRA; ?model=<model_code> keeps the ones that go on that model (unknown model: 404). Each entry also carries a direct lora_url and its sha256, used by Imference Desktop to run them locally.

curl 'https://imference.com/api/loras?model=cyberrealistic-xl'
# → {"loras": [{"lora_code": "detail-tweaker-xl", "compatible_family_codes": ["illustrious", "pony", "sdxl"],
#               "weight_default": 1.5, "weight_min": -3, "weight_max": 3, "trigger_words": [], …}]}
CodeNameGoes onWeight (default · range)Trigger words
2000s-analog-core-zimage2000s Analog Core
Early-2000s Camcorder Look
zimage0.9 · 0 to 1.5·
add-micro-details-concept-krea2Add Micro Details - Concept
Crisp Micro Details
krea20.25 · 0 to 1.5·
aesthetic-quality-modifiers-masterpiece-krea2Aesthetic Quality Modifiers - Masterpiece
Masterpiece Aesthetic Boost
krea20.8 · 0 to 1.5masterpiece, very aesthetic
anime-flat-style-animaAnime Flat Style
Anime Flat-Color Style
anima0.8 · 0 to 1.5·
anime-flat-style-krea2Anime Flat Style
Bold Anime Flat Colors
krea20.8 · 0 to 1.5·
anime-flat-style-zimageAnime Flat Style
Flat-Color Anime Style
zimage0.8 · 0 to 1.5·
anime-in-real-animaAnime in real
Anime in Real Backgrounds
anima0.8 · 0 to 1.5@Ani3rel
cat-citron-styles-illustriousCAT - Citron Styles
Citron Bold Toon-Gloss Style
illustrious1 · 0 to 1.5bokeh, luminescent background,
dark-art-style-animaDark Art Style
Dark Art Anime Look
anima1 · 0.7 to 1.2dark_art_style
dark-art-style-illustriousDark Art Style
Cinematic Dark Fantasy Style
illustrious1 · 0.7 to 1.2dark_art_style
dark-art-style-krea2Dark Art Style
Cinematic Dark-Fantasy Look
krea21 · 0.7 to 1.2dark_art_style
dark-art-style-zimageDark Art Style
Cinematic Dark Art Style
zimage1 · 0.7 to 1.2dark_art_style
dc-vivid-dark-fantasy-painting-zimageDC Vivid Dark Fantasy Painting
Vivid Dark Fantasy Painting
zimage0.8 · 0.6 to 1dcdrkfntsy.
detail-tweaker-animaDetail Tweaker
Detail Tweaker for Anima
anima0.8 · -0.75 to 0.8·
detail-tweaker-xlDetail Tweaker XL
Adjustable Detail for SDXL
illustrious, pony, sdxl1.5 · -3 to 3·
expressiveh-hentai-lora-styleExpressiveH
ExpressiveH: Glossy Anime Vibe
pony0.8 · 0 to 1.5Expressiveh
lenovo-ultrareal-krea2Lenovo UltraReal
Ultra-Real Phone Camera Vibe
krea20.6 · 0 to 1.5·
moriimee-gothic-niji-lora-styleMoriiMee Gothic Niji LoRA Style
MoriiMee Gothic Niji Style
illustrious0.9 · 0 to 1.5·
moriimee-gothic-niji-lora-style-krea2MoriiMee Gothic Niji LoRA Style
Gothic Jirai Kei Gloss & Cyan
krea20.8 · 0 to 1.5·
moriimee-gothic-niji-lora-style-zimageMoriiMee Gothic Niji LoRA Style
MoriiMee Gothic Niji Look
zimage0.8 · 0 to 1.5·
nsfw-v4-krea2NSFW V4
Realistic Skin for Adult Scenes
krea21.25 · 0.8 to 2·
realistic-snapshot-krea2Realistic Snapshot
Phone-Camera Realism, Candid Vibe
krea21.5 · 0 to 2·
retro-sci-fi-90s-anime-style-animaRetro Sci-fi 90's anime style
Retro 90s Sci-Fi Anime Look
anima0.8 · 0.6 to 1.2retro_scifi_90s_anime_style, retro_artstyle, retro,
retro-sci-fi-90s-anime-style-illustriousRetro Sci-fi 90's anime style
Retro 90s Anime Sci-Fi Style
illustrious0.8 · 0 to 1.5retro_artstyle, retro, cyberpunk
retro-sci-fi-90s-anime-style-krea2Retro Sci-fi 90's anime style
90s Retro Sci-Fi Anime Style
krea20.8 · 0.6 to 1.2retro_scifi_90s, retro_artstyle, retro, cyberpunk
retro-sci-fi-90s-anime-style-zimageRetro Sci-fi 90's anime style
90s Retro Sci-Fi Anime Style
zimage0.8 · 0.6 to 1.2retro_scifi_90s, retro_artstyle, retro, cyberpunk,
velvets-mythic-fantasy-styles-animaVelvet's Mythic Fantasy Styles
Epic Inked Anime Style
anima1 · 0.5 to 1.5Smo0thL1nes
velvets-mythic-fantasy-styles-flux-pony-illustriVelvet's Mythic Fantasy Styles illustrious
Mythic Fantasy Anime Glow
illustrious1 · 0.5 to 1.5C0lorL1nes

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, unknown or incompatible LoRA
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.