Image Generation Guide
API examples for GPT Image 2.5 Sunburst / Flare, gpt-image-2 and Gemini image models.
modelsok offers several AI image models. The base URL is https://modelsok.com, authenticated with Authorization: Bearer <API Key>. This page explains how to call each model and shares practical tips.
Available models
| Model | Notes | Endpoint |
|---|---|---|
gpt-image-2.5-sunburst | Text-to-image; verified 1024×1024 PNG output | OpenAI-compatible |
gpt-image-2.5-flare | Text-to-image; verified 1024×1024 PNG output | OpenAI-compatible |
gpt-image-2 | OpenAI image model, output size matches the request exactly, up to 3840×2160 | OpenAI-compatible |
gemini-2.5-flash-image-preview | Gemini fast image | OpenAI-compatible / Gemini native |
gemini-2.5-flash-image | Gemini fast image | Gemini native |
gemini-3.1-flash-image-preview | Gemini fast image | Gemini native |
gemini-3-pro-image-preview | Gemini high-quality image | Gemini native |
GPT Image 2.5: Sunburst / Flare
Both models use the same endpoint and authentication. Switch models by changing only model. Text-to-image requests were verified on both serving channels on September 9, 2026. The example below uses the verified minimal parameters. Check your account's model catalog for availability and pricing.
curl --max-time 300 https://modelsok.com/v1/images/generations \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2.5-sunburst",
"prompt": "An orange ceramic robot holding a sunflower against a blue background, studio product photography",
"n": 1,
"size": "1024x1024"
}'For Flare, change model to gpt-image-2.5-flare. The synchronous response contains Base64 image data in data[0].b64_json; decode it to save a PNG. The example omits response_format and quality.
Use asynchronous submission for long-running requests
Append ?async=true to the submission URL to receive a task id. Poll with the same API key:
Known gateway limitation: an API key with model restrictions enabled may receive a 403 model-access error while polling, even if generation succeeded. Use the synchronous example for these keys for now. Do not disable production key restrictions or resubmit an already-created task to work around this error. This is not a model-generation failure.
curl "https://modelsok.com/v1/tasks/$TASK_ID" \
-H "Authorization: Bearer $API_KEY"Poll every 3–5 seconds. Keep waiting while state is queued or processing; read image results from data.images when it is succeeded, and inspect error details when it is failed. Asynchronous results differ from the synchronous data[].b64_json structure. Save the task ID and resume polling after a query timeout instead of submitting another billable generation.
A 300-second client timeout does not extend the CDN timeout. Prefer asynchronous submission when encountering HTTP 524.
If data.images[].url is a relative path (for example, /api/relay-temp-images/…png), resolve it against https://modelsok.com before downloading. Download and save the image promptly; temporary image URLs are not permanent storage.
Verification currently covers one 1024×1024 text-to-image output per request. Other resolutions, quality tiers, image editing and performance differences between the two models have not been verified for this guide. Do not infer their limits, default quality or price multipliers from the gpt-image-2 section below.
gpt-image-2
Size rules
The output size exactly matches the requested size. That size must satisfy all three conditions below, otherwise the API returns an explicit error (it never silently falls back to a different size):
| Condition | Error when violated |
|---|---|
| Width and height must both be multiples of 16 | Width and height must both be divisible by 16 |
| Total pixels between 655,360 and 8,294,400 | below / exceeds the current pixel budget |
| Longest edge ≤ 3840 | The longest edge must be less than or equal to 3840 |
Common sizes:
| Aspect ratio | Valid size |
|---|---|
| 1:1 | 1024x1024, 2048x2048 |
| 4:3 / 3:4 | 1024x768, 2048x1536 / 768x1024, 1536x2048 |
| 3:2 / 2:3 | 1536x1024 / 1024x1536 |
| 5:4 / 4:5 | 1280x1024 / 1024x1280 |
| 16:9 / 9:16 | 2048x1152, 3840x2160 / 1152x2048, 2160x3840 |
| 21:9 | 2688x1152 |
4096x4096 is rejected because it exceeds the longest-edge limit. Use 3840x2160 for 4K.
Quality tiers
The optional quality parameter accepts low / medium / high and defaults to low. It affects quality, latency and price at the same time, so specify it explicitly based on your use case.
| quality | Relative price | Latency (1024×1024) | Suggested use |
|---|---|---|---|
low (default) | 1× | ~26s | Drafts, batch previews |
medium | ~9× | ~43s | Everyday production |
high | ~36× | ~109s | Final deliverables |
Text to image
curl https://modelsok.com/v1/images/generations \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "a red panda eating bamboo, flat vector illustration",
"size": "1024x1024",
"quality": "medium"
}'Image to image / editing
Pass a publicly reachable image URL in the image field — no file upload needed. Pass an array to submit multiple reference images (up to 16).
curl https://modelsok.com/v1/images/edits \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "make the mug matte black, keep the composition unchanged",
"image": "https://your-cdn/reference.png",
"size": "3840x2160",
"quality": "medium"
}'gpt-image-2 does not accept the response_format parameter — sending it returns
400 Unknown parameter: 'response_format'. Results are always returned as b64_json (Base64 image data).
Response example:
{
"created": 1780888000,
"data": [{ "b64_json": "iVBORw0KGgoAAAANSUhEUgAA..." }]
}Python example
import base64, requests
resp = requests.post(
"https://modelsok.com/v1/images/edits",
headers={"Authorization": f"Bearer {API_KEY}"},
json={
"model": "gpt-image-2",
"prompt": "a red panda eating bamboo, flat vector illustration",
"image": "https://your-cdn/reference.png",
"size": "2048x2048",
"quality": "medium",
},
timeout=300,
)
data = resp.json()["data"][0]["b64_json"]
open("out.png", "wb").write(base64.b64decode(data))A single image-to-image call typically takes 20–110 seconds (longer at higher
quality). Set your client timeout to at least 300 seconds and add retries.
Gemini models
Option 1: OpenAI-compatible endpoint
Works for gemini-2.5-flash-image-preview.
curl https://modelsok.com/v1/images/generations \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-2.5-flash-image-preview",
"prompt": "a red panda eating bamboo, flat vector illustration",
"n": 1,
"size": "1024x1024",
"response_format": "b64_json"
}'Prefer
response_format: "b64_json". The defaulturlreturns a temporary object-storage link that may expire and occasionally times out on download. Usingb64_jsongives you the image data directly and is more robust to integrate. This parameter is available for Gemini models only —gpt-image-2does not support it.
Option 2: Gemini native endpoint
Works for all Gemini image models. Note the trailing slash in the path.
curl "https://modelsok.com/v1beta/models/gemini-2.5-flash-image:generateContent/" \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"contents": [{ "parts": [{ "text": "a blue cartoon cat, white background" }] }]
}'Note: the Gemini native endpoint usually returns the image as a Markdown image link embedded in text (under
candidates[0].content.parts[].text, like) rather than asinlineData. Extract the URL from the text and download it. To get standard image data directly, usegemini-2.5-flash-image-previewvia the OpenAI-compatible endpoint instead.
Response example:
{
"candidates": [{
"content": {
"role": "model",
"parts": [{ "text": "" }]
}
}]
}Billing
gpt-image-2 is billed by token usage — the cost depends on the output size (size), the quality tier (quality) and the reference image size. Larger outputs and higher tiers cost more. The other image models are billed per call (a fixed amount per generation).
See the Model Marketplace for exact prices, which vary by account tier.