from 3 credits per call
AI Image Generation API
Generate images from a text prompt with a single JSON request. Up to four samples per call, three models to trade speed against quality, and full commercial rights on the output.
- REST · JSON
- No watermark
- Nothing stored
POST /v1/generate-image
What is the AI Image Generation API?
The ImgGen AI image generation API is a REST endpoint that turns a text prompt into images. You send a JSON body with the prompt, how many samples you want, an aspect ratio, and which model to use; the endpoint returns the generated images base64-encoded in an array. It is the only endpoint that takes JSON rather than a file.
It is one of seven endpoints in the ImgGen AI image editing API, all of which share a single API key, a single base URL, and the same request and response shape. If you also need this capability in a browser rather than from code, the same AI model powers the AI Image Generator tool.
Request parameters
Send a POST request to https://app.imggen.ai/v1/generate-image, authenticated with an API key in the Authorization header.
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
| prompt | string | REQUIRED | — | Text description of the image to generate. |
| samples | number | optional | 1 | How many images to generate, from 1 to 4. |
| aspect_ratio | string | optional | square | Output shape. Accepts square, portrait or landscape. |
| model | string | optional | imggen-base | Generation model. Accepts imggen-base, imggen-base-fast or imggen-xl. |
How do I integrate the AI image generation API?
Create an API key in your ImgGen account, set it as an environment variable, and call the endpoint. Here is the same request in cURL, Node.js and Python.
curl --request POST \
--url 'https://app.imggen.ai/v1/generate-image' \
--header 'Authorization: Bearer sk_live_YOUR_API_KEY' \
--header 'Content-Type: application/json' \
--data '{
"prompt": "close up photo of a rabbit in a wildflower meadow",
"samples": 1,
"aspect_ratio": "square",
"model": "imggen-base"
}'import fs from 'node:fs';
const res = await fetch('https://app.imggen.ai/v1/generate-image', {
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.IMGGEN_API_KEY}`,
'Content-Type': 'application/json',
},
body: JSON.stringify({
prompt: 'close up photo of a rabbit in a wildflower meadow',
samples: 1,
aspect_ratio: 'square',
model: 'imggen-base',
}),
});
const data = await res.json();
data.images.forEach((img, i) =>
fs.writeFileSync(`image-${i}.png`, Buffer.from(img, 'base64')),
);import base64, os, requests
res = requests.post(
"https://app.imggen.ai/v1/generate-image",
headers={
"Authorization": f"Bearer {os.environ['IMGGEN_API_KEY']}",
"Content-Type": "application/json",
},
json={
"prompt": "close up photo of a rabbit in a wildflower meadow",
"samples": 1,
"aspect_ratio": "square",
"model": "imggen-base",
},
)
for i, img in enumerate(res.json()["images"]):
with open(f"image-{i}.png", "wb") as out:
out.write(base64.b64decode(img))Response
A successful call returns JSON. The result is base64-encoded — decode it before writing to disk or object storage. Every successful response also carries an X-Credit-Remaining header with your balance after the call.
{
"success": true,
"message": "Images generated successfully",
"images": ["iVBORw0KGgoAAAANSUhEUgAA...SUVORK5CYII="]
}Limits and behaviour worth knowing
The endpoint accepts JPEG (JPG), PNG and WebP with a 25 MB maximum file size, and responds synchronously within 60 seconds — there is no job to poll and no webhook to configure.
Returns an images array
Unlike the editing endpoints, which return a single image field, generation returns images — an array with one entry per sample requested.
Three models
imggen-base is the default balance, imggen-base-fast trades detail for speed, and imggen-xl targets the highest quality. Pick per request rather than per account.
JSON, not multipart
This is the only endpoint that takes a JSON body. Send Content-Type: application/json instead of a multipart form.
What is the AI image generation API used for?
Where teams put this endpoint into production to process images programmatically, at scale.
Editorial and blog imagery
Generate an original header image per article from the headline, instead of pulling from a stock library everyone else uses.
Product and campaign concepting
Produce four variations of a visual idea in one call so a team can pick a direction before commissioning real work.
In-app creative features
Let your users generate images inside your product without you standing up GPU infrastructure.
Placeholder and mock content
Fill demos, prototypes, and seeded environments with plausible imagery generated on demand.
How much does the AI image generation API cost?
Each successful call costs from 3 credits, so your effective cost per image follows whichever plan you are on. Credits come from your plan and are shared across every endpoint and the web editor, so you are not buying a separate quota per tool. A call that fails is refunded automatically. See the full pricing page for details.
| Plan | Price | Credits | API |
|---|---|---|---|
| Free | $0 | 50 one-time free credits | No API access |
| Starter | $9.99 / month | 400 credits / month | API access included |
| Pro | $29.99 / month | 1,400 credits / month | API access + priority support |
| Enterprise | Custom | Custom volume | Dedicated infrastructure |
Credit costs and limits last verified 2026-08-27.
Related endpoints and tools
Teams using the AI image generation API usually reach for these next.
Also available: Watermark Removal, Text Removal, Photo Restoration, Photo Colorization.
AI Image Generation API FAQ
- It is an HTTP endpoint that turns a written description into an image. You send a prompt as JSON and the service returns generated images in the response, which lets a product offer text-to-image without running any model infrastructure of its own.
- Between one and four, set with the samples parameter. All requested images come back in a single images array in the same response.
- Three: imggen-base is the default and balances quality against speed, imggen-base-fast returns results more quickly with less detail, and imggen-xl targets the highest quality. You choose per request via the model parameter.
- square, portrait and landscape, set with aspect_ratio. It defaults to square if you leave it out.
- Generation is priced per model rather than at a flat rate, because the models differ substantially in compute. It starts at 3 credits per image on the default model and rises for the higher-quality ones. Your remaining balance comes back on the X-Credit-Remaining header of every successful call, and the live cost for each model is shown in your ImgGen account.
- You do. ImgGen does not claim ownership of anything the API returns, and every plan carries full commercial usage rights with no watermark. Bear in mind that copyright in AI-generated images is treated differently across jurisdictions, so if ownership is legally load-bearing for your use case, check your local position.
- Yes. Every plan, including Free, includes full commercial usage rights, and no output carries a watermark. You can sell, print, or publish anything the API returns.
- Generated images are returned in the response and not retained. As with every ImgGen endpoint, the only thing kept is a usage log recording that a call happened and what it cost. Your content is not used to train models.
Get started
Start calling the AI Image Generation API
One key unlocks all seven endpoints. No watermark, full commercial rights, and nothing you send is stored after the response is returned.
Get your API key