Image Generation
Image Generation
Generate stunning images from text prompts using world-class models — GPT-Image-2, Seedream, Imagen 4, Flux, Wan, and more. BelugAPI transparently handles async polling so you always get back image URLs directly.
Transparent async. Image generation is async internally, but BelugAPI polls until the images are ready and returns the URLs directly — you don't need to implement polling yourself.
POST
https://api.belugapi.com/v1/images/generations
Async (handled)
Requires Authorization: Bearer bapi_… header.
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| model | string | required | Image model ID — see table below. |
| prompt | string | required | Text description of the image to generate. |
| n | integer | optional | Number of images to generate. Default: 1. Max: 4 (model-dependent; GPT-Image models: 1). |
| size | string | optional | Aspect ratio label: 1:1, 16:9, 9:16, 4:3, 3:4, 3:2, 2:3, 5:4, 4:5, 2:1, 1:2, 21:9, 9:21, auto. Default: 1:1. |
| quality | string | optional | standard or hd (model-dependent). |
| response_format | string | optional | url (default) or b64_json. |
Basic example — GPT-Image-2
from openai import OpenAI client = OpenAI( api_key="bapi_your_key_here", base_url="https://api.belugapi.com/v1" ) result = client.images.generate( model="gpt-image-2", prompt="A photorealistic beluga whale swimming through crystal clear arctic water, 4K", size="16:9", n=1, ) print(result.data[0].url)
import OpenAI from "openai"; const client = new OpenAI({ apiKey: "bapi_your_key_here", baseURL: "https://api.belugapi.com/v1" }); const result = await client.images.generate({ model: "gpt-image-2", prompt: "A photorealistic beluga whale swimming through crystal clear arctic water, 4K", size: "16:9", n: 1, }); console.log(result.data[0].url);
curl https://api.belugapi.com/v1/images/generations \ -H "Authorization: Bearer bapi_your_key_here" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-2", "prompt": "A photorealistic beluga whale swimming through crystal clear arctic water, 4K", "size": "16:9", "n": 1 }'
Response
200 OK
{
"created": 1716900000,
"data": [
{
"url": "https://cdn.example.com/generated/image-abc123.png"
}
]
}
Seedream (ByteDance)
result = client.images.generate( model="seedream-4.5", prompt="Anime-style warrior princess in a cherry blossom garden, vibrant colors", size="9:16", )
curl https://api.belugapi.com/v1/images/generations \ -H "Authorization: Bearer bapi_your_key_here" \ -H "Content-Type: application/json" \ -d '{ "model": "seedream-4.5", "prompt": "Anime-style warrior princess in a cherry blossom garden, vibrant colors", "size": "9:16" }'
Imagen 4.0 (Google)
result = client.images.generate( model="gpt-image-2", prompt="Hyper-realistic product photo of a glass bottle of mineral water, studio lighting", size="1:1", )
curl https://api.belugapi.com/v1/images/generations \ -H "Authorization: Bearer bapi_your_key_here" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image-2", "prompt": "Hyper-realistic product photo of a glass bottle of mineral water, studio lighting", "size": "1:1" }'
Flux 2.0
result = client.images.generate( model="flux-2.0", prompt="Oil painting of a Renaissance-style portrait of a tech entrepreneur", size="3:4", )
curl https://api.belugapi.com/v1/images/generations \ -H "Authorization: Bearer bapi_your_key_here" \ -H "Content-Type: application/json" \ -d '{ "model": "flux-2.0", "prompt": "Oil painting of a Renaissance-style portrait of a tech entrepreneur", "size": "3:4" }'
Wan 2.7 Image
result = client.images.generate( model="wan2.7-image-pro", prompt="Futuristic city skyline at night with neon reflections on rain-soaked streets", size="21:9", )
curl https://api.belugapi.com/v1/images/generations \ -H "Authorization: Bearer bapi_your_key_here" \ -H "Content-Type: application/json" \ -d '{ "model": "wan2.7-image-pro", "prompt": "Futuristic city skyline at night with neon reflections on rain-soaked streets", "size": "21:9" }'
Available image models
| Model ID | Name | Provider | Aspect ratios / sizes |
|---|---|---|---|
gpt-image-2 |
GPT-Image-2 | OpenAI | auto, 1:1, 16:9, 9:16, 4:3 … |
gpt-image-2-official |
GPT-Image-2 (Official Channel) | OpenAI | auto, 1:1, 16:9, 9:16, 4:3 … |
gpt-image-1-official |
GPT-Image-1 | OpenAI | 1:1, 16:9, 9:16, 4:3, 3:4 |
gpt-image-1.5-official |
GPT-Image-1.5 | OpenAI | 1:1, 16:9, 9:16, 4:3, 3:4 |
gemini-3-pro-image-preview-official |
Gemini 3 Pro Image (Nano Banana Pro) | 1:1, 16:9, 9:16, 4:3, 3:4 | |
gemini-2.5-flash-image-preview-official |
Gemini 2.5 Flash Image (Nano Banana) | 1:1, 16:9, 9:16, 4:3, 3:4 | |
seedream-4.0 |
Seedream 4.0 | ByteDance | 1:1, 16:9, 9:16, 4:3, 3:4 |
seedream-4.5 |
Seedream 4.5 | ByteDance | 1:1, 16:9, 9:16, 4:3, 3:4 |
seedream-5.0-lite |
Seedream 5.0 Lite | ByteDance | 1:1, 16:9, 9:16, 4:3, 3:4 |
wan2.7-image |
Wan 2.7 Image | Various | — |
wan2.7-image-pro |
Wan 2.7 Image Pro | Various | — |
qwen-image-2.0-pro |
Qwen Image 2.0 Pro | Various | — |
z-image-turbo |
Z-Image-Turbo | Various | — |
grok-imagine-1.0-apimart |
Grok Imagine 1.0 | Various | — |
grok-imagine-1.0-edit-apimart |
Grok Imagine 1.0 Edit | Various | — |
flux-kontext |
Flux Kontext | Various | — |
flux-2.0 |
Flux 2.0 | Various | — |
Size / aspect ratio reference
Use these values in the size field. Pixel-style values like 1024x1024 are accepted for compatibility but are automatically converted.
| Value | Description | Best for |
|---|---|---|
| 1:1 | Square | Social media, avatars, icons |
| 16:9 | Landscape widescreen | Thumbnails, banners, wallpapers |
| 9:16 | Portrait (mobile) | Stories, Reels, Shorts |
| 4:3 | Classic landscape | Presentations, print |
| 3:4 | Portrait | Photos, posters |
| 21:9 | Ultra-wide | Cinematic headers |
| 3:2 | DSLR landscape | Photography-style |
| auto | Model decides | Let the AI choose |