Image Generation API
A unified REST API to generate images using 15+ AI models — supporting text-to-image and image-to-image generation with multiple output formats, all through a single endpoint with a credit-based pricing system.
Endpoints
| Method | Path | Description |
|---|---|---|
POST | /generate/text-image | Generate an image from a text prompt. |
POST | /generate/image-image | Generate an image from one or more input images (image-to-image). |
Parameters
Request body fields for /generate/text-image:
| Parameter | Type | Required | Default | Description |
|---|---|---|---|---|
model | string | Yes | — | Model ID to use for generation. See the model list below for all available IDs. |
prompt | string | Yes | — | Text description of the image you want to generate. |
width | number | No | 512 | Output image width in pixels. |
height | number | No | 512 | Output image height in pixels. |
outputType | string | No | "binary" | Output delivery format. One of "binary" (image blob), "url" (hosted link), or "base64" (encoded string). |
outputFormat | string | No | "png" | Image file format. Either "png" or "jpg". |
image | string[] | No | — | Array of input image URLs (max 3). Required only for image-to-image generation. |
Response example
binary
const blob = await response.blob();
const url = URL.createObjectURL(blob);
url
{
"success": true,
"taskId": "imagegpt_img-...",
"url": "https://...",
"creditsDeducted": 3
}
base64
{
"success": true,
"taskId": "imagegpt_img-...",
"base64": "/9j/4QWm...",
"creditsDeducted": 3
}
Examples
Text-to-image (fetch)
fetch('https://api.imagegpt.online/generate/text-image', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
model: 'FLUX-SCHNELL',
prompt: 'A futuristic city at sunset, photorealistic',
width: 512,
height: 512,
outputType: 'url',
outputFormat: 'png'
})
})
.then(res => res.json())
.then(data => console.log('Image URL:', data.url));
Image-to-image (body)
body: JSON.stringify({
model: 'FLUX-KONTEXT',
prompt: 'Turn this photo into an oil painting',
image: ['https://example.com/input.jpg'],
outputType: 'url'
})
Pricing
Charged in credits per image. Each image deducts the credit value shown for the selected model.
Models
Each model has its own page with parameters, examples, and a live playground.
| Model | Model ID | Credits / image |
|---|---|---|
| Flux Schnell | FLUX-SCHNELL | 3 |
| Z Image Turbo | ZIMAGE-TURBO | 5 |
| GPT Image 1.0 | GPT-IMAGE-1 | 10 |
| GPT Image 1.5 | GPT-IMAGE-1.5 | 25 |
| GPT Image 2.0 | GPT-IMAGE-2 | 35 |
| GPT Image 2.5 Flare | GPT-IMAGE-2.5-FLARE | 35 |
| Nano Banana | NANOBANANA | 10 |
| Nano Banana 2 Lite | NANOBANANA-2-LITE | 10 |
| Nano Banana 2 | NANOBANANA-2 | 40 |
| Nano Banana 2.1 | NANOBANANA-2.1 | 20 |
| Nano Banana Pro | NANOBANANA-PRO | 100 |
| Seedream | SEEDREAM | 25 |
| Seedream 4.0 | SEEDREAM 4.0 | 35 |
| Seedream Lite 5.0 | SEEDREAM LITE 5.0 | 35 |
| Ideogram | IDEOGRAM | 35 |
| Qwen Image | QWEN-IMAGE | 30 |
| Flux Kontext | FLUX-KONTEXT | 25 |
| Wan Image 2.7 | WAN-IMAGE-2.7 | 40 |
| Grok Imagine | GROK-IMAGE | 20 |