Image generation
Call GPT Image, Gemini (Nano Banana) and other image models with the OpenAI Images format, at 1K / 2K / 4K.
Endpoint
POST https://api.onefast.ai/v1/images/generations # text-to-image
POST https://api.onefast.ai/v1/images/edits # image-to-image / inpainting (multipart)
Authorization: Bearer sk-xxx
All image models are called with the OpenAI Images format, and images are returned as Base64 (b64_json).
Text-to-image
cURL
curl https://api.onefast.ai/v1/images/generations \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2.5",
"prompt": "A cute corgi astronaut, studio lighting",
"size": "1024x1024",
"n": 1
}' | python3 -c "import sys,json,base64; open('out.png','wb').write(base64.b64decode(json.load(sys.stdin)['data'][0]['b64_json']))"
Python
import base64
from openai import OpenAI
client = OpenAI(api_key="sk-xxx", base_url="https://api.onefast.ai/v1")
result = client.images.generate(
model="gpt-image-2.5",
prompt="A cute corgi astronaut, studio lighting",
size="1024x1024",
)
with open("out.png", "wb") as f:
f.write(base64.b64decode(result.data[0].b64_json))
Node.js
import fs from "node:fs";
import OpenAI from "openai";
const client = new OpenAI({ apiKey: "sk-xxx", baseURL: "https://api.onefast.ai/v1" });
const result = await client.images.generate({
model: "gpt-image-2.5",
prompt: "A cute corgi astronaut, studio lighting",
size: "1024x1024",
});
fs.writeFileSync("out.png", Buffer.from(result.data[0].b64_json, "base64"));
Image generation usually takes 20–60 seconds. Set your HTTP client timeout to 300 seconds or more.
Common parameters
| Parameter | Description |
|---|---|
model |
Required. Image model; see the model catalog (filter by "Image") |
prompt |
Required. Description of the image |
size |
Size as WIDTHxHEIGHT (lowercase x), e.g. 1024x1024, 1536x1024 |
n |
Number of images, default 1 |
quality |
Quality. GPT Image: low / medium / high / auto; for Gemini see below |
background |
GPT Image supports transparent (transparent background, with PNG) |
output_format |
GPT Image supports png / jpeg / webp |
Gemini images (Nano Banana) and 4K
Gemini image models such as gemini-3.1-flash-image-preview and gemini-3-pro-image-preview use the same endpoint. The gateway decides the resolution tier and aspect ratio as follows:
Resolution (1K / 2K / 4K) — quality takes precedence; otherwise the longest side of size decides:
| You send | Tier |
|---|---|
"quality": "4k", or longest side of size ≥ 3000 |
4K |
"quality": "2k" / "hd", or longest side of size ≥ 1600 |
2K |
| Anything else | 1K |
Aspect ratio — taken from the width-to-height ratio of size and snapped to the nearest standard ratio (1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 21:9).
cURL
curl https://api.onefast.ai/v1/images/generations \
-H "Authorization: Bearer $API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gemini-3.1-flash-image-preview",
"prompt": "A watercolor lighthouse at dawn",
"size": "3840x2160"
}'
The example above produces a 16:9 4K image. Exact pixel dimensions are determined by the model (for example, 2K at 16:9 is about 2752×1536). The output may be PNG or JPEG — check the file header.
Image-to-image / editing
Upload the source image (multipart form) and describe the change in prompt:
cURL
curl https://api.onefast.ai/v1/images/edits \
-H "Authorization: Bearer $API_KEY" \
-F model="gpt-image-2.5" \
-F image="@input.png" \
-F prompt="Add a red scarf to the dog"
Python
result = client.images.edit(
model="gpt-image-2.5",
image=open("input.png", "rb"),
prompt="Add a red scarf to the dog",
)
Gemini image models accept several reference images in one request (up to 14, field name image[]) and do not support mask.
Billing
- Some groups charge per image (regardless of size), others per token (output image tokens at the output price). The listed price for that group in the model catalog applies.
- Failed requests are not billed.