Image Generation API
Supported Models
openai/gpt-image-1
openai/dall-e-2
openai/dall-e-3
Parameters
n
integer or null
Optional
1
1–10
Only n=1
is supported for dall-e-3
.
output_format
string or null
Optional
png
png
, jpeg
, webp
Only supported for gpt-image-1
.
quality
string or null
Optional
auto
auto
, high
, medium
, low
, hd
, standard
gpt-image-1
: auto
, high
, medium
, low
dall-e-3
: auto
, hd
, standard
dall-e-2
: standard
only
size
string or null
Optional
auto
auto
, 1024x1024
, 1536x1024
, 1024x1536
, 256x256
, 512x512
, 1792x1024
, 1024x1792
gpt-image-1
: auto
, 1024x1024
, 1536x1024
, 1024x1536
dall-e-2
: 256x256
, 512x512
, 1024x1024
dall-e-3
: 1024x1024
, 1792x1024
, 1024x1792
background
string or null
Optional
auto
transparent
, opaque
, auto
Only supported for gpt-image-1
. If set to transparent
, output_format
must be png
or webp
. auto
lets the model decide the best background.
OpenAI Compatible Image Request Format
FastRouter offers an OpenAI-compatible request schema.
import base64
import openai
client = openai.OpenAI(
api_key="API-KEY",
base_url="https://go.fastrouter.ai/api/v1"
)
img = client.images.generate(
model="openai/gpt-image-1",
prompt="A cute baby sea otter",
n=1,
size="1024x1024"
)
image_base64 = img.data[0].b64_json
image_bytes = base64.b64decode(image_base64)
# Save the image to a file
with open("otter.png", "wb") as f:
f.write(image_bytes)
Calling FastRouter Directly
curl --location 'https://go.fastrouter.ai/api/v1/images/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: Bearer API-KEY' \
--data '{
"model": "openai/dall-e-3",
"prompt": "A group of children playing cricket",
"n": 1,
"size": "1024x1024"
}'
Last updated