跳转到内容

GPT Image 2 API

集成

模型 id openai/gpt-image-2
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.com/v1/run/openai/gpt-image-2?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
  }'

# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.com/v1/requests/REQUEST_ID?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY"

此请求: ≈$0.106 106 API 积分 在此页面运行

获取 API 密钥
OpenAI 文生图 #gpt-image-2#openai#typography#chatgpt-images-2

GPT Image 2 文生图,支持边长最高 3840px 的灵活尺寸,专注于精细排版

在 Doitong 上制作

Doitong 社区使用 GPT Image 2 API 制作的公开作品。一键复用提示词。

显示的公开作品:16
Создай не меняя черты лица. Фотореалистичный винтажный cinematic portrait. В кадре большое наполь...

Создай не меняя черты лица. Фотореалистичный винтажный cinematic portrait. В кадре большое напольное зеркало в тонкой арочной раме. Спиной к камере у зеркала стоит взрослая девушка-, корпус развёрнут к своему отражению, голова слегка повёрнута в профиль, взгляд направлен в зеркало на свою...

Создай не меняя черты лица. Фотореалистичный винтажный cinematic portrait. В кадре большое наполь...

Создай не меняя черты лица. Фотореалистичный винтажный cinematic portrait. В кадре большое напольное зеркало в тонкой арочной раме. Спиной к камере у зеркала стоит взрослая девушка-, корпус развёрнут к своему отражению, голова слегка повёрнута в профиль, взгляд направлен в зеркало на свою...

Create image: ultra realistic image: man 35 years old sitting in super luxury house (ref4). Luxur...

Create image: ultra realistic image: man 35 years old sitting in super luxury house (ref4). Luxury furniture, marble floor with east carpet. The most luxurious way. Middle shot One cake in front of him on the marble table, with thin golden lit candles. A man sits relaxed on a luxurious sofa. The...

Create image: ultra realistic image: man 35 years old sitting in super luxury house. Luxury furni...

Create image: ultra realistic image: man 35 years old sitting in super luxury house. Luxury furniture, marble floor with east carpet. The most luxurious way. Middle shot One cake in front of him on the marble table, with thin golden lit candles. A man sits relaxed on a luxurious sofa. The man is...

Сделай этикетку на продукцию оформленную красиво и стильно в соответствии с составом. Можешь орие...

Сделай этикетку на продукцию оформленную красиво и стильно в соответствии с составом. Можешь ориентироваться по стилю на фото 1. Текст на этикетке: производитель ИП Стрини Ю.Л. «соломка горбуши», состав: рыба горбуша, соль, сахар, специи. Срок хранения при t не от 0 до -3 60 суток. Вес: 500гр

Create image: ultra realistic image: man 35 years old (attached reference ) sitting in super luxu...

Create image: ultra realistic image: man 35 years old (attached reference ) sitting in super luxury house. Luxury furniture, marble floor with east carpet. The most luxurious way. Middle shot One cake in front of him on the marble table, with thin golden lit candles. A man sits relaxed on a...

Create image: ultra realistic image: man 35 years old sitting in super luxury house. Luxury furni...

Create image: ultra realistic image: man 35 years old sitting in super luxury house. Luxury furniture, marble floor with east carpet. The most luxurious way. Middle shot One cake in front of him on the marble table, with thin golden lit candles. A man sits relaxed on a luxurious sofa. The man is...

Art style: 3D stylized animation. Вид сверху: босые ступни стоят на стильных электронных весах. Э...

Art style: 3D stylized animation. Вид сверху: босые ступни стоят на стильных электронных весах. Экран мягко подсвечивает цифру 70кг. Светлое пушистое ковровое покрытие с фото 2, виднеющееся по краям, озарено тёплым солнечным светом. Кадр лаконичен и целиком сосредоточен на дисплее....

构建请求

控件根据模型架构生成。更改控件时,代码和价格会同步更新。

•必填 88 / 32000

用于生成图像的提示词。

image_size 默认 landscape_4_3

输出尺寸接受预设名称、{width, height} 对象,或让模型选择最佳尺寸的 'auto'。所有具体尺寸都要求各边可被 16 整除、边长不超过 3840px、宽高比不超过 3:1,且总像素数为 655,360–8,294,400。

num_images 默认 1

要生成的图像数量。

高级 background · quality · output_format · enable_safety_checker
background 默认 auto

结果图像的背景。

quality 默认 high

图像质量选择,包括由模型根据提示词选择最佳质量的 'auto'。

output_format 默认 png

输出图像的文件格式。

POST /run/openai/gpt-image-2?wait=20 报价 → $0.106
# Run the model; wait up to 20 s for the finished result in the same call
curl -X POST "https://api.doitong.com/v1/run/openai/gpt-image-2?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
  }'

# Still "queued" or "running"? Poll with the id from the response:
curl "https://api.doitong.com/v1/requests/REQUEST_ID?wait=20" \
  -H "Authorization: Bearer $DOITONG_API_KEY"

运行此请求

你的密钥会保留在此浏览器中:仅发送到 Doitong API;只有勾选“记住”后才会保存到 localStorage。 获取 API 密钥

关于 GPT Image 2 API

根据最多 32000 个字符的提示词生成图像。`image_size` 接受预设、auto 或明确的宽度和高度,其中两个尺寸都必须是 16 的倍数,最大边长为 3840px。质量可设为 auto、low、medium 或 high,每次调用最多生成 4 张 png、jpeg 或 webp 图像。

参数

发送规范名称或原生名称之一,不要同时发送两者。 规范名称

名称类型 默认值允许值 描述
prompt必填
类型string
≤ 32,000 个字符≥ 2 个字符
用于生成图像的提示词。
image_size可选
类型object
默认值landscape_4_3
square_hdsquareportrait_4_3portrait_16_9landscape_4_3landscape_16_9auto
输出尺寸接受预设名称、{width, height} 对象,或让模型选择最佳尺寸的 'auto'。所有具体尺寸都要求各边可被 16 整除、边长不超过 3840px、宽高比不超过 3:1,且总像素数为 655,360–8,294,400。
background可选
类型enum
默认值auto
autotransparentopaque
结果图像的背景。
quality可选
类型enum
默认值high
autolowmediumhigh
图像质量选择,包括由模型根据提示词选择最佳质量的 'auto'。
num_images可选 num_outputs
类型integer
默认值1
1 – 4
要生成的图像数量。
output_format可选
类型enum
默认值png
jpegpngwebp
输出图像的文件格式。
enable_safety_checker可选
类型boolean
默认值true
调用方获得授权后,可将其设置为 false 以放宽审核。
必填 规范名称,也可接受

输出

GET /requests/req_8k2m4q7x1z9c3v5b6n0p2r4t
{
  "id": "req_8k2m4q7x1z9c3v5b6n0p2r4t",
  "object": "request",
  "model": "openai/gpt-image-2",
  "status": "succeeded",
  "created_at": "2026-10-20T12:00:00Z",
  "started_at": "2026-10-20T12:00:02Z",
  "completed_at": "2026-10-20T12:00:09Z",
  "queue_position": null,
  "cost": {
    "credits": 106,
    "usd": "0.106",
    "charged": 106,
    "refunded": 0
  },
  "input": {
    "prompt": "A red fox trots through fresh snow at sunrise, soft golden light, shallow depth of field"
  },
  "output": {
    "images": [
      {
        "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
        "content_type": "image/jpeg",
        "file_name": "0-output.jpeg",
        "file_size": 1843200,
        "width": 1024,
        "height": 768
      }
    ]
  },
  "outputs": [
    {
      "type": "image",
      "url": "https://content.doitong.com/dev-api/2026/10/20/req_8k2m4q7x1z9c3v5b6n0p2r4t/0-output.jpeg",
      "content_type": "image/jpeg",
      "file_size": 1843200,
      "width": 1024,
      "height": 768,
      "stored": true
    }
  ],
  "error": null,
  "metrics": {
    "inference_seconds": 6.8
  },
  "urls": {
    "self": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t",
    "cancel": "https://api.doitong.com/v1/requests/req_8k2m4q7x1z9c3v5b6n0p2r4t/cancel"
  }
}
你的文件,由你选择每个 outputs[].url 都是存储中的副本:可永久保存(按 GB-月付费),也可免费保存 7 天,由账户设置或 ?storage= 决定。
每个模型的结构相同图像、视频和音频均包含 type、url、content_type、width、height 和 duration。output 是模型自身的结果对象。
输出字段
images
array of object {url, content_type, file_name, file_size, width, height}模型生成的图像。

更多模型:文生图

对于 AI 代理:此页面的 Markdown 版本位于 https://doitong.com/zh/developers/models/openai/gpt-image-2.md. 所有模型和指南: https://doitong.com/developers/llms.txt