Transform your ideas into stunning images and videos with our powerful AI models
Test and explore the Image Generation API with multiple models and output formats
fetch('https://api.imagegpt.online/generate/text-image', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'x-api-key': 'YOUR_API_KEY'
},
body: JSON.stringify({
"prompt": "Photorealistic portrait of the same person (keep his real face unchanged). A man with medium curly brown hair, light skin, and soft features sits relaxed, forearms on a light blue table, holding a small white puppy with a red collar. He wears a cozy color-block knitted sweater (beige, tan, light blue, black) with ribbed neck and cuffs, a silver watch, and a turquoise-beaded bracelet. Soft diffused lighting, smooth steel-blue background, slightly elevated front angle warm, intimate, digital photo",
"width": 512,
"height": 512,
"model": "FLUX-SCHNELL",
"outputType": "binary",
"outputFormat": "png"
})
})
.then(response => response.blob())
.then(blob => {
const imageUrl = URL.createObjectURL(blob);
console.log('Image URL:', imageUrl);
// Display in img tag: document.getElementById('myImg').src = imageUrl;
})
.catch(error => console.error('Error:', error));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.
https://api.imagegpt.online/generate/text-imageAll requests must include your API key in the request header. Keep your API key secret and never expose it in client-side code in production.
x-api-key: YOUR_API_KEYMissing or invalid API key returns a 401 Unauthorized response.
Send a JSON body with the following fields:
| Parameter | Type | Default | Description |
|---|---|---|---|
model* | string | — | Model ID to use for generation. See the model list above for all available IDs. |
prompt* | string | — | Text description of the image you want to generate. |
width | number | 512 | Output image width in pixels. |
height | number | 512 | Output image height in pixels. |
outputType | string | "binary" | Output delivery format. One of "binary" (image blob), "url" (hosted link), or "base64" (encoded string). |
outputFormat | string | "png" | Image file format. Either "png" or "jpg". |
image | string[] | — | Array of input image URLs (max 3). Required only for image-to-image generation. |
* Required fields.
The response shape depends on the outputType you chose:
outputType: "binary"
const blob = await response.blob();
const url = URL.createObjectURL(blob);outputType: "url"
{
"success": true,
"taskId": "imagegpt_img-...",
"url": "https://...",
"creditsDeducted": 3
}outputType: "base64"
{
"success": true,
"taskId": "imagegpt_img-...",
"base64": "/9j/4QWm...",
"creditsDeducted": 3
}A minimal working text-to-image request using the fetch API:
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));For image-to-image, add an image array:
body: JSON.stringify({
model: 'FLUX-KONTEXT',
prompt: 'Same person, wearing a red jacket',
image: ['https://example.com/input.jpg'],
width: 512,
height: 512,
outputType: 'url',
outputFormat: 'png'
})Credits are charged per image generated. The badge next to each model shows its credit cost:
Fast, lightweight models ideal for drafts and prototypes.
e.g. Flux Schnell, Z Image Turbo
Balanced quality for everyday generation tasks.
e.g. GPT Image 1.0, Seedream, Nova Canvas
Highest fidelity for production-quality output.
e.g. Nano Banana Pro, Seedream 4.0, Ideogram
ImageGPT prohibits NSFW, sexually explicit, adult, exploitative, deceptive, or harmful AI-generated content. Content moderation is applied to supported image and video generation.