Image Generation
Text-to-image
POST /v1/images/generations· Image-to-imagePOST /v1/images/edits· Token groupmedia / media-gen
Available Models
| Model name | Description | Resolution | Reference images |
|---|---|---|---|
gpt-image-2 | OpenAI image model · Same price for 1K / 2K / 4K | 1K · 2K · 4K | ≤6 |
gpt-image-2.5 | OpenAI image model (newer generation) · Same price for 1K / 2K / 4K | 1K · 2K · 4K | ≤6 |
gemini-3.0-pro-image-ultra | Google Gemini 3 Pro Image (Nano Banana Pro) · Same price for 1K / 2K / 4K | 1K · 2K · 4K | ≤1 |
gemini-3.1-flash-image-ultra | Google Gemini 3.1 Flash Image (Nano Banana 2) · Same price for 1K / 2K / 4K | 1K · 2K · 4K | ≤1 |
gemini-nano-banana-2.1-ultra | Google Nano Banana 2.1 · Same price for 1K / 2K / 4K | 1K · 2K · 4K | ≤1 |
The three Gemini models use POST /v1beta/models/{model}:generateContent. Put the prompt and reference image in contents[].parts; set generationConfig.imageConfig (aspectRatio / imageSize: "1K" / "2K" / "4K"). Image results are in candidates[].content.parts, as inlineData (base64) or fileData.fileUri (image URL). The playground handles both automatically.
Express resolution / aspect ratio via the size parameter
In the API, pass size (width x height in pixels) to set the aspect ratio. Examples: "1024x1024" = 1:1, "1024x576" = 16:9. In the playground, just click to select. See live pricing in the Generation Playground.
Easiest: Use the Generation Playground
- Open the Generation Playground and stay on the "🖼 Image" tab
- Enter your token (from the
media / media-gengroup) - Pick a model → write your prompt → choose an aspect ratio / resolution → click "Generate"
- Once the image is ready you can download it directly, and your history is kept too
Image-to-Image (Reference Images)
Upload reference images and let the model generate or edit based on them (change the style, tweak details, combine multiple images, and more):
- Playground: click the "Reference image" area to upload — multiple images supported (limits per the table above, each ≤8MB)
- API: use
POST /v1/images/edits(multipart; theimagefile field can be passed multiple times), see Calling via the API
Supported Aspect Ratios
Commonly 1:1 · 16:9 · 9:16 · 4:3 · 3:4; some models also support 21:9, 3:2, 2:3, etc. — go by the options shown for that model in the Generation Playground.
How to Write Prompts
- Be specific: subject + scene + style + lighting. Example: "At dusk, a golden retriever running through a golden wheat field, cinematic, shallow depth of field"
- If you want a certain quality or style (realistic, illustration, 3D, cyberpunk, etc.), just say so
- Both Chinese and English work
Integrating Into Your Program
For the full API format plus code examples, see Calling via the API. If something goes wrong, check Common Errors.
