Skip to main content
POST
Text-to-Image: generate at an explicit size from a text prompt
The interactive Playground on the right supports direct online testing. Enter your API Key in the Authorization field (format: Bearer sk-xxx), set prompt and size, then click send.
Scope: This page is for text-to-image generation. Just enter a prompt and size — no image upload required. To edit or fuse existing images, use the Image Editing endpoint.Difference vs gpt-image-2-all: identical call structure, just one extra size field. If you don’t need to lock dimensions and want fastest output, use gpt-image-2-all instead.
🖥️ Browser Playground limitationThis endpoint returns a base64 string (b64_json) by default, which can be several MB, so the browser Playground may show 请求时发生错误: unable to complete requestthe request actually succeeded; the browser just can’t render such a long base64 string.Recommended workflow: copy the code sample below and run it locally — it decodes the image and saves it to a file automatically.
All image APIs are synchronous — there is no task ID to poll, and if your client disconnects the result is lost while the request is still billed. Set a generous timeout for this model; see Image API Essentials & Best Practices.
⚠️ Key parameter notes
  • size: pass auto to let the model choose (vip tends to converge on a relatively fixed/stable size for a given prompt), or pick one of the 30 supported sizes (10 ratios × 1K Fast / 2K Recommended / 4K Detail — see the full size table on the overview page) for strict locking. Use lowercase ASCII x, e.g., 2048x1360, 3840x2160 — never × or uppercase X.
  • quality: ❌ rejected — do not pass.
  • n: ❌ rejected — single image per call. Sending n=3 charges 3× but still returns 1 image. Drop the field.
  • aspect_ratio: ❌ rejected — ratio is determined by size.
  • response_format: omitting it returns base64 (raw, no prefix, verified 2026-07); pass "url" for an image URL. Businesses that depend on URL output should switch their token to the image2_OSS group for deterministic URL output with no base64 fallback.

Code Examples

Python

4K Detail tier example (wallpaper / print):

cURL

Node.js

Parameters

Size cheat-sheet — these cover most cases:
  • E-commerce hero shots: 2048x1360 (3:2 2K) / 2048x2048 (1:1 2K)
  • Vertical posters: 1536x2048 (3:4 2K) / 2480x3312 (3:4 4K)
  • Video thumbnails: 2048x1152 (16:9 2K) / 3840x2160 (16:9 4K)
  • Story / phone wallpapers: 1152x2048 (9:16 2K) / 2160x3840 (9:16 4K)
Full 30-size table: overview page.

Response Format

Returns base64 by default (data[0].b64_json, raw base64 without prefix, verified 2026-07). To get an image URL instead, pass response_format: "url" explicitly; businesses that depend on URL output should switch their token’s group to image2_OSS for stable URL output with no base64 fallback. data[0] returns either url or b64_json — never both. b64_json mode (default):
url mode (pass response_format: "url" explicitly; use the image2_OSS group if you depend on URLs — R2 CDN globally accelerated):
Compatibility note: verified July 2026 — the b64_json field is raw base64 without the data: prefix; decode it to write a file, or prepend the prefix yourself before rendering. Earlier versions did include the prefix, so always run a startsWith('data:') check first to handle both shapes.

Model Overview (full size table)

Complete 30-size table, pricing, technical specs

Image Editing API

/v1/images/edits multi-image fusion and editing

Sister model gpt-image-2-all

Same call format when you don’t need locked size — faster output (~30–60s)

Authorizations

Authorization
string
header
required

API Key from the API易 Console

Body

application/json
model
enum<string>
default:gpt-image-2-vip
required

Model name, fixed to gpt-image-2-vip

Available options:
gpt-image-2-vip
prompt
string
required

Prompt — describe content, style, lighting, etc.

Example:

"Cinematic landscape, old lighthouse by the sea at dusk, photorealistic"

size
enum<string>

Output size. Pass auto to let the model decide (vip tends to converge on a relatively fixed size for a given prompt), or pick one of the 30 supported sizes (10 ratios × 1K Fast / 2K Recommended / 4K Detail) to lock it strictly. Format: WIDTHxHEIGHT with lowercase ASCII x, e.g., 2048x1360, 3840x2160. Flat $0.03/image across all tiers.

Available options:
auto,
1280x1280,
848x1280,
1280x848,
960x1280,
1280x960,
1024x1280,
1280x1024,
720x1280,
1280x720,
1280x544,
2048x2048,
1360x2048,
2048x1360,
1536x2048,
2048x1536,
1632x2048,
2048x1632,
1152x2048,
2048x1152,
2048x864,
2880x2880,
2336x3520,
3520x2336,
2480x3312,
3312x2480,
2560x3216,
3216x2560,
2160x3840,
3840x2160,
3840x1632
Example:

"2048x1152"

Response

Image successfully generated. Defaults to base64 in data[0].b64_jsonurl is not returned in the same response.

Image generation response. Returns base64 by default (data[0].b64_json); to get a url, switch to the image2_OSS group with response_format=url. data[0] returns either url or b64_json, never both.

data
object[]

Result array (this model returns 1 image per call)

created
integer

Unix timestamp (seconds)

usage
object

Token usage statistics