POST
/
v1
/
images
/
generations
curl -X POST "https://api.applerouter.ai/v1/images/generations/" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-1",
    "prompt": "A cute baby sea otter",
    "n": 1,
    "size": "1024x1024"
  }'
{
  "created": 1713833628,
  "data": [
    {
      "url": "https://example.com/generated-image.png"
    }
  ],
  "usage": {
    "total_tokens": 100,
    "input_tokens": 50,
    "output_tokens": 50,
    "input_tokens_details": {
      "text_tokens": 10,
      "image_tokens": 40
    }
  }
}

Overview

Create images from text prompts using DALL-E, GPT-Image, and other compatible models.
prompt
string
required
A text description of the desired image (Prompt) (DALL-E 3 max 4000 characters)
model
string
The model to use: dall-e-2, dall-e-3, or gpt-image-1
n
integer
The number of images to generate (1-10, DALL-E 3 supports n=1 only)
size
string
Image size: - DALL-E 2: 256x256, 512x512, 1024x1024 - DALL-E 3: 1024x1024, 1792x1024, 1024x1792 - GPT-Image-1: 1024x1024, 1536x1024, 1024x1536, auto
quality
string
The quality of the image that will be generated
background
string
Background transparency: transparent, opaque, or auto (GPT-Image-1 only)
curl -X POST "https://api.applerouter.ai/v1/images/generations/" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-1",
    "prompt": "A cute baby sea otter",
    "n": 1,
    "size": "1024x1024"
  }'
{
  "created": 1713833628,
  "data": [
    {
      "url": "https://example.com/generated-image.png"
    }
  ],
  "usage": {
    "total_tokens": 100,
    "input_tokens": 50,
    "output_tokens": 50,
    "input_tokens_details": {
      "text_tokens": 10,
      "image_tokens": 40
    }
  }
}

Authorizations

Authorization
string
header
required

使用 Bearer Token 认证。格式: Authorization: Bearer sk-xxxxxx

Body

application/json
prompt
string
required

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

model
string

用于图像生成的模型。dall-e-2dall-e-3gpt-image-1 之一。默认为 dall-e-2,除非使用特定于 gpt-image-1 的参数。

n
integer

要生成的图像数量。必须介于 1 到 10 之间。对于 dall-e-3,仅支持 n=1

size
string

生成的图像的大小。对于 gpt-image-1,必须是 1024x10241536x1024(横向)、1024x1536(纵向)或自动(默认值)之一,对于 dall-e-2,必须是 256x256、``512x5121024x1024 之一,对于 dall-e-3,必须是 1024x10241792x10241024x1792 之一。

background
string

允许为生成的图像的背景设置透明度。此参数仅支持 gpt-image-1。必须是以下之一 透明不透明自动(默认值)。使用自动时,模型将自动确定图像的最佳背景。

如果是透明的,则输出格式需要支持透明度,因此应将其设置为 png(默认值)或 webp

moderation
string

控制 gpt-image-1 生成的图像的内容审核级别。必须为低, 以进行限制较少的筛选或自动(默认值)。

quality
string

将生成的图像的质量。

stream
string
style
string
user
string

Response

200 - application/json
created
integer
required
data
object[]
required
usage
object
required