跳转到主要内容
POST
/
v1
/
images
/
generations
curl -X POST "https://api.lemondata.cc/v1/images/generations" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "dall-e-3",
    "prompt": "一只白猫坐在窗台上看雨",
    "size": "1024x1024",
    "quality": "standard",
    "n": 1
  }'
{
  "created": 1706000000,
  "data": [
    {
      "url": "https://...",
      "revised_prompt": "一只毛茸茸的白猫,眼睛明亮,安静地坐在木质窗台上,看着雨滴顺着玻璃窗流下..."
    }
  ]
}

请求体

model
string
默认值:"dall-e-3"
使用的模型(例如 dall-e-3flux-promidjourney)。
prompt
string
必填
描述所需图像的文本。
n
integer
默认值:"1"
要生成的图像数量(1-4,取决于模型)。
size
string
默认值:"1024x1024"
图像尺寸。选项因模型而异:
  • DALL-E 3: 1024x10241792x10241024x1792
  • 其他模型: 512x5121024x1024
quality
string
默认值:"standard"
图像质量(standardhd)。仅限 DALL-E 3。
response_format
string
默认值:"url"
响应格式:urlb64_json
style
string
默认值:"vivid"
DALL-E 3 的风格:vividnatural
user
string
终端用户的唯一标识符。

响应

同步响应(DALL-E、Flux Schnell 等)

created
integer
创建时间的 Unix 时间戳。
data
array
生成的图像数组。每个对象包含:
  • url (string): 生成图像的 URL
  • b64_json (string): Base64 编码的图像(如果请求)
  • revised_prompt (string): 使用的提示词(DALL-E 3)

异步响应(Midjourney、Flux Pro、Ideogram 等)

某些模型需要更长的处理时间,会返回异步响应:
created
integer
创建时间的 Unix 时间戳。
task_id
string
用于轮询的唯一任务标识符。
status
string
初始状态:pending
poll_url
string
用于轮询结果的相对 URL(例如 /v1/images/generations/{task_id})。
data
array
包含占位数据的数组。url 在完成前为空。
当收到 status: "pending" 时,使用获取图像状态端点轮询结果。
curl -X POST "https://api.lemondata.cc/v1/images/generations" \
  -H "Authorization: Bearer sk-your-api-key" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "dall-e-3",
    "prompt": "一只白猫坐在窗台上看雨",
    "size": "1024x1024",
    "quality": "standard",
    "n": 1
  }'
{
  "created": 1706000000,
  "data": [
    {
      "url": "https://...",
      "revised_prompt": "一只毛茸茸的白猫,眼睛明亮,安静地坐在木质窗台上,看着雨滴顺着玻璃窗流下..."
    }
  ]
}

可用模型

模型类型特点
dall-e-3同步最佳质量,提示词增强
dall-e-2同步更快,更实惠
flux-pro异步照片级真实感,高质量
flux-schnell同步非常快
midjourney异步艺术风格
ideogram-v3异步最佳文字渲染
stable-diffusion-3同步开源,可定制
异步模型返回 status: "pending",需要轮询。请参阅获取图像状态了解如何获取结果。

请求体

application/json
prompt
string
必填

描述所需图像的文本。

model
string

使用的模型(例如 dall-e-3flux-promidjourney )。

n
integer

要生成的图像数量(1-4,取决于模型)。

size
string

图像尺寸。选项因模型而异: DALL-E 3: 1024x10241792x10241024x1792 其他模型: 512x5121024x1024

quality
string

图像质量( standardhd )。仅限 DALL-E 3。

response_format
string

响应格式: urlb64_json

style
string

DALL-E 3 的风格: vividnatural

user
string

终端用户的唯一标识符。

响应

200 - application/json

Response 200

created
integer

创建时间的 Unix 时间戳。

data
object[]

包含占位数据的数组。 url 在完成前为空。

task_id
string

用于轮询的唯一任务标识符。

status
string

初始状态: pending

poll_url
string

用于轮询结果的相对 URL(例如 /v1/images/generations/{task_id} )。