Skip to main content
POST
OpenAI image generations
Create images from text prompts.

GPT Image 2

  • Set model: "gpt-image-2" explicitly to use GPT Image 2; when model is omitted, ApiGo defaults to dall-e-2
  • gpt-image-2 supports text-to-image generation, flexible sizes, and low, medium, high, or auto quality
  • When size or quality is omitted, ApiGo uses 1024x1024 and medium; explicitly send auto if you want the model to choose
  • For a custom size, both edges must be multiples of 16, the aspect ratio must not exceed 3:1, each edge must be at most 3840 px, and total pixels must be between 655,360 and 8,294,400
  • background accepts opaque or auto; gpt-image-2 does not currently support transparent
  • Images are returned in data[].b64_json. Decode the value and save it using output_format, which defaults to png
For jpeg and webp, use output_compression (0–100) to control compression. moderation accepts auto or low. Complex prompts can take close to two minutes, so configure a sufficient client timeout. For edits, inpainting, or multi-image composition, use /v1/images/edits.

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
prompt
string
required

描述目标图片的文本提示词。

Example:

"一只可爱的小猫在花园里玩耍,阳光明媚,油画风格"

model
enum<string>
default:dall-e-2

图片生成模型;未传时 ApiGo 使用 dall-e-2。

Available options:
gpt-image-2,
gpt-image-1,
dall-e-3,
dall-e-2
background
enum<string>

GPT Image 模型支持。gpt-image-2 仅支持 opaque 和 auto,不支持 transparent。

Available options:
transparent,
opaque,
auto
moderation
enum<string>

GPT Image 模型支持 auto 和 low。

Available options:
auto,
low
n
integer
default:1

生成图片的数量;dall-e-3 仅支持 1。

Required range: 1 <= x <= 10
output_compression
integer
default:100

GPT Image 模型生成 JPEG/WebP 时的压缩率。

Required range: 0 <= x <= 100
output_format
enum<string>

GPT Image 模型支持 png、jpeg 和 webp。

Available options:
png,
jpeg,
webp
quality
enum<string>

不同模型支持的值不同。GPT Image 未传时,ApiGo 使用 medium。

Available options:
auto,
high,
medium,
low,
hd,
standard
response_format
enum<string>

仅适用于 dall-e-2 和 dall-e-3。

Available options:
url,
b64_json
size
string

允许值取决于模型。gpt-image-2 支持 auto 或符合尺寸约束的自定义分辨率;未传时 ApiGo 使用 1024x1024。

Example:

"1024x1024"

style
enum<string>

仅 dall-e-3 支持。

Available options:
vivid,
natural
user
string

终端用户的唯一标识。

Response

Successful image generation response

created
integer<int64>
required

Unix 时间戳,单位为秒。

data
object[]
required
background
enum<string>
Available options:
transparent,
opaque,
auto
output_format
enum<string>
Available options:
png,
jpeg,
webp
quality
enum<string>
Available options:
auto,
high,
medium,
low,
hd,
standard
size
string
usage
object