How an AI image generator API works
An AI image generator API takes a text prompt in a POST request and returns a finished image, usually as a link or as base64 data you save to a file. Ours runs FLUX models from Black Forest Labs: the standard endpoint returns a 1024×1024 JPEG for $0.03, and the HD endpoint lets you pick the size and a seed for $0.06. There's no sign-up or API key, and you can try both free 5 times a day.
Try it free Image Generation API — pictures from a text prompt · $0.03 / call
Two endpoints, two jobs
| Image API | Image HD API | |
|---|---|---|
| Model | FLUX.1 [schnell] | FLUX.2 [klein] 4B |
| Price per image | $0.03 | $0.06 |
| Size | Always 1024×1024 | 256 to 1536 px each side (rounded to 16) |
| Seed | No | Yes, so you can repeat a result |
| Body | prompt, steps (1–8, default 6) | prompt, width, height, seed |
| Good for | Drafts, thumbnails, square posts | Banners, portrait or wide images, readable text in the picture |
The request
Both endpoints take JSON. Prompts can be up to 2,000 characters.
POST https://iamai.markets/api/x402/services/ij0SpjTJvY-K
Content-Type: application/json
{"prompt": "a red bicycle leaning on a white wall, morning light, photo", "steps": 6}
POST https://iamai.markets/api/x402/services/pBOfMSmBCVNq
Content-Type: application/json
{"prompt": "poster with the words OPEN LATE in bold letters, neon sign style",
"width": 1536, "height": 864, "seed": 42}
Paying and decoding the image
- The first answer is HTTP 402 with the price.
- An x402 v2 client (or Coinbase AgentKit with the iamai-agentkit npm plugin) pays in USDC on Base and repeats the request with the PAYMENT-SIGNATURE header.
- The 200 answer holds result.image_base64 (a JPEG), content_type, width, height and model. Decode the base64 and write it to a .jpg file, or put it straight into an img tag as a data URL.
// Browser or Node 18+, after your x402 client has paid and repeated the call
const { result } = await res.json();
const src = `data:${result.content_type};base64,${result.image_base64}`;
document.querySelector("#preview").src = src;
What it won't do
- Prompts asking for sexual, violent, hateful or self-harm images are refused, and a refused call isn't charged.
- The standard endpoint has no size choice and no seed. If you need either, use HD.
- No editing of an existing image, no inpainting and no image-to-image: text in, image out.
- Images come back as base64, not a hosted link, so store them yourself.
Other image APIs
| Option | What it's like | Account needed |
|---|---|---|
| OpenAI image API | Strong prompt following, image editing too | Yes, API key and billing |
| Stability AI API | Stable Diffusion family, many tools (upscale, edit) | Yes, credits |
| Replicate, fal.ai | Many open models including FLUX, billed by usage | Yes |
| Cloudflare Workers AI | Runs FLUX models on your own Cloudflare account | Yes, Cloudflare account |
| iamai.markets Image / Image HD | $0.03 / $0.06 per image, text to image only | No, pay per call with x402 |
The product
Questions
Can I use the images commercially?
The model's licence allows commercial use of the outputs. Check that your prompt doesn't copy someone else's brand or character.
I don't have a crypto wallet. Can I still use it?
Yes. The AI Image Generator is also on RapidAPI with monthly card plans, starting with a free plan of 10 images: https://rapidapi.com/VPNKorp/api/ai-image-generator32
Do I pay if the generation fails?
No. You're only charged when the call works, and refused prompts cost nothing.
Related
Updated 2026-12-01
