跳转到主要内容
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",
  "mode": "dall-e-2",
  "moderation": "auto",
  "n": 123,
  "output_compression": "100",
  "output_format": "png",
  "quality": "auto",
  "response_format": "<string>",
  "size": "auto",
  "style": "vivid(生动)"
}
'
{
  "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
  }
}

OpenAI Image Models

TTAPI整合openai的优秀图片模型,让你能以更为优惠的价格且方便的方式集成到你的服务。
gpt-image-1 模型官方耗时比较长,建议使用我们的 https://api.ttapi.org 网关,避免请求超时

授权

TT-API-KEY
string
header
必填

授权字段,控制台获取授权信息

请求体

application/json
prompt
string
必填

图像的文本描述。gpt-image-1 的最大长度为 32000 个字符,dall-e-2 的最大长度为 1000 个字符,dall-e-3 的最大长度为 4000 个字符。

background
enum<string>
默认值:auto

允许设置生成图像背景的透明度
此参数仅适用于 gpt-image-1。可选值 transparentopaqueauto(默认)之一。使用 auto 时,模型将自动确定图像的最佳背景。
如果设置为透明,则输出格式需要支持透明度,因此应设置为 png 或 webp。

可用选项:
transparent,
opaque,
auto
mode
enum<string>
默认值:dall-e-2

支持模型

可用选项:
gpt-image-1,
dall-e-2,
dall-e-3
moderation
enum<string>
默认值:auto

控制 gpt-image-1 生成的图片的内容审核级别。low(用于限制较少的过滤)或 auto(默认值)。

可用选项:
low,
auto
n
integer

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

output_compression
integer
默认值:100

生成图像的压缩级别(0-100%)。此参数仅支持输出格式为 webp 或 jpeg 的 gpt-image-1,默认为 100。

output_format
enum<string>
默认值:png

返回图像格式。此参数仅适用于 gpt-image-1。可选值 png(默认)、jpeg 、 webp 。

可用选项:
png,
png,
jpeg
quality
string
默认值:auto

图片质量。可选范围:
auto(默认值)将自动为给定模型选择最佳质量。
gpt-image-1 支持highmediumlow三种质量。
dall-e-3 支持 hdstandard
dall-e-2 仅支持 standard

response_format
string

返回数据格式
dall-e-3, dall-e-2 支持 urlb64_json,url有效期为60分钟,请获取到数据后第一时间缓存。
gpt-image-1 仅支持 b64_json

size
string
默认值:auto

图像尺寸
gpt-image-1 可选范围1024x1024,1536x1024,1024x1536,auto(默认)
dall-e-2 可选范围256x256,512x512,1024x1024
dall-e-3 可选范围1024x1024,1792x1024,1024x1792
注意:不同尺寸消耗ttapi quota不同

style
enum<string>

生成图像的风格 此参数仅支持 dall-e-3。

可用选项:
vivid(生动),
natural(自然)

响应

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

created
integer
必填

生成时间戳(秒)

示例:

1745818538

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

图像生成结果列表

usage
object
Last modified on March 12, 2026