Generate Images with gpt-image-2 Through One Endpoint: Size, Count, Response and Cost
CQTAI
10/28/2026

If you already generate images with an OpenAI-style API, gpt-image-2 needs no new SDK and no new habits. It lives behind the same endpoint as every other image model on CQTAI: POST /v1/images/generations, a Bearer key, JSON in, JSON out.
This guide covers the parts that decide whether your first call works: the request, the response, the size you ask for, and what a call costs.
The request
curl https://api.novapi.ai/v1/images/generations \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "A minimalist poster-style illustration of a lighthouse on a cliff at dusk, flat vector style, teal and orange palette. No text.",
"size": "1536x1024",
"n": 1
}'
Only model and prompt are required. size defaults to 1024x1024 when you leave it out. quality is optional, and a model page lists the values it accepts.
The response
The image comes back as a URL in data[0].url:
{
"created": 1761600000,
"data": [ { "url": "https://.../image.png" } ]
}
Download it right away and keep your own copy. A result URL is a delivery link, not storage you should build on, so copy the file to your own bucket or CDN before you show it to users.

The picture above is the actual output of the request in this post, 1536x1024, unedited.
Pick a size on purpose
The size decides the aspect ratio, and the aspect ratio decides how you can use the picture:
| You are making | Try |
|---|---|
| Avatars, product tiles, social squares | 1024x1024 |
| Blog covers, banners, slides (landscape) | 1536x1024 |
| Posters, phone wallpapers (portrait) | 1024x1536 |
Do not ask for a size and then crop it in CSS if you can ask for the right shape in the first place. Composition is generated for the frame you request, so a landscape request puts the subject where a landscape needs it. For a banner with text over one side, say so in the prompt, for example "keep the left 40% calm and dark".
Time and cost
Image models are slow compared with chat. Expect a call to take from tens of seconds to about a minute, so set your HTTP client timeout to at least two minutes, and do not retry while the first request is still in flight, or you pay twice.
Images are charged per image, and the price is known before you call. The public model list shows it without a key:
curl https://api.novapi.ai/v1/models
Look for gpt-image-2 and read pricing. It reads like this when the list price is 6 points per image:
{ "id": "gpt-image-2", "category": "image", "pricing": { "request": "6", "unit": "points_per_image" } }
On the international site 1 USD is 100 points, so 6 points is 6 cents. Treat that number as an example and read the live value from the list, because prices change. Points are taken before the call runs, and the charge appears in your usage records.
Python and TypeScript
import os, requests
r = requests.post(
"https://api.novapi.ai/v1/images/generations",
headers={"Authorization": "Bearer " + os.environ["API_KEY"]},
json={"model": "gpt-image-2", "prompt": "a lighthouse at dusk, flat vector", "size": "1536x1024"},
timeout=180,
)
r.raise_for_status()
url = r.json()["data"][0]["url"]
open("lighthouse.png", "wb").write(requests.get(url, timeout=60).content)
const res = await fetch("https://api.novapi.ai/v1/images/generations", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
model: "gpt-image-2",
prompt: "a lighthouse at dusk, flat vector",
size: "1536x1024",
}),
signal: AbortSignal.timeout(180_000),
});
if (!res.ok) throw new Error(await res.text());
const { data } = await res.json();
console.log(data[0].url);
Common mistakes
- Too short a timeout. A 30 second timeout turns a successful job into a paid failure on your side. Use two minutes or more.
- Retrying blindly. If a request timed out on your side, it may still have been accepted. Check your usage before you send it again.
- Asking the model to write text. Long or small text inside an image is where image models are least reliable. Put real text on top of the image in your UI.
- Hard-coding the price. Read it from
/v1/modelsor you will be wrong the day a price changes. - Using the wrong key type.
/v1/*accepts API keys. A login token from the website will be rejected.
Next, read how to write prompts that gpt-image-2 follows, or compare it with the other families in choosing an AI image model.