Skip to main content
POST
/
v1
/
images
/
generations
cURL
curl --request POST \
  --url https://api.ttapi.io/v1/images/generations \
  --header 'Content-Type: application/json' \
  --header 'TT-API-KEY: <api-key>' \
  --data '
{
  "prompt": "<string>",
  "background": "auto",
  "moderation": "auto",
  "n": 123,
  "output_compression": 100,
  "output_format": "png",
  "partial_images": 0,
  "quality": "auto",
  "size": "auto",
  "stream": false,
  "user": "<string>"
}
'
{
  "created": 1745818538,
  "data": [
    {
      "url": "https://filesystem.site/cdn/20250428/5LsFMT0Def02RVVUkwJ4v7IslleMzo.webp",
      "revised_prompt": "A cute fluffy cat with big, bright eyes, soft fur, and a playful expression. It has a light gray coat with hints of white on its paws and tail. The cat is sitting in a cozy setting, surrounded by soft cushions, with its tail wrapped around its paws. Its ears are perked up, and it's looking directly at the viewer, exuding a sense of curiosity and warmth."
    }
  ],
  "usage": {
    "input_tokens": 9,
    "input_tokens_details": {
      "image_tokens": 0,
      "text_tokens": 9
    },
    "output_tokens": 4160,
    "total_tokens": 4169
  }
}

Documentation Index

Fetch the complete documentation index at: https://docs.ttapi.io/llms.txt

Use this file to discover all available pages before exploring further.

根据文本提示创建图像。该接口与 OpenAI 官方 Images API 的 POST /v1/images/generations 请求和响应结构保持一致,文档翻译自 官方文档,如已对接官方文档可直接使用,入参出参结构与支持保持一致。”。 支持模型包括 gpt-image-2gpt-image-1.5gpt-image-1dall-e-2dall-e-3

Authorizations

TT-API-KEY
string
header
required

请前往 TTAPI 控制台 获取 API 密钥。

Body

application/json
prompt
string
required

图像的文本描述。gpt-image-1.5gpt-image-1 最多支持 32000 个字符;dall-e-2 最多支持 1000 个字符;dall-e-3 最多支持 4000 个字符。

model
enum<string>
required

用于图像生成的模型。

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

设置生成图像背景的透明度。仅适用于 GPT Image 模型。可选值为 transparentopaqueauto(默认)。当设置为 transparent 时,output_format 必须支持透明度,请使用 pngwebp

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

控制 GPT Image 模型生成图像的内容审核级别。可选 low(限制更少的过滤)或 auto(默认)。

Available options:
low,
auto
n
integer

要生成的图像数量,默认值为 1。可选范围 1-10dall-e-3 固定为 1。

output_compression
integer
default:100

生成图像的压缩级别(0-100)。仅适用于 output_formatwebpjpeg 的 GPT Image 模型,默认值为 100。

output_format
enum<string>
default:png

生成图像的返回格式。仅适用于 GPT Image 模型。可选 png(默认)、jpegwebp

Available options:
png,
jpeg,
webp
partial_images
integer
default:0

流式响应中要返回的部分图片数量,范围 0-3,默认值为 0。仅当 streamtrue 时可用。

quality
string
default:auto

图像质量。auto(默认)会为给定模型自动选择最佳质量。

GPT Image 模型支持 highmediumlow

dall-e-3 支持 hdstandard

dall-e-2 仅支持 standard

response_format
enum<string>

返回数据格式。仅 dall-e-2dall-e-3 支持 urlb64_json;URL 有效期为 60 分钟。GPT Image 模型始终返回 b64_json

Available options:
url,
b64_json
size
string
default:auto

图像尺寸。

GPT Image 模型支持 1024x10241536x10241024x1536auto(默认);

gpt-image-2 支持 WIDTHxHEIGHT 任意分辨率字符串,宽高需可被 16 整除,宽高比需在 1:3 到 3:1 之间。

dall-e-2 支持 256x256512x5121024x1024

dall-e-3 支持 1024x10241792x10241024x1792

stream
boolean
default:false

是否以流式方式返回生成进度。启用后可通过 partial_images 获取部分图片事件。

style
enum<string>

生成图像的风格。仅适用于 dall-e-3

Available options:
vivid(生动),
natural(自然)
user
string

代表最终用户的唯一标识,可帮助 OpenAI 监测和检测滥用。

Response

请求成功,返回图像生成结果(支持url/base64两种格式)

created
integer
required

生成时间戳(秒)

Example:

1745818538

data
(URL格式 · object | Base64格式 · object)[]
required

图像生成结果列表

usage
object
Last modified on May 20, 2026