Skip to main content
POST
/
v1
/
images
/
generations
文生图
curl --request POST \
  --url https://api.chenyu.cn/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "prompt": "<string>",
  "size": "<string>",
  "n": 123,
  "response_format": "<string>"
}
'
{
  "created": 123,
  "data": [
    {
      "url": "<string>"
    }
  ]
}

文生图

使用 OpenAI Images 兼容格式生成图片。

请求参数

model
string
required
图片生成模型 ID
prompt
string
required
图片生成提示词
size
string
图片尺寸,例如 1024x10242k3k。网关会自动适配上游模型的尺寸要求
n
integer
生成图片数量
response_format
string
返回格式,通常为 url

响应参数

created
integer
创建时间戳
data
array
生成结果列表

代码示例

import requests

url = "https://api.chenyu.cn/v1/images/generations"
headers = {
    "Authorization": "Bearer your_api_key",
    "Content-Type": "application/json"
}
payload = {
    "model": "doubao-seedream-5-0-lite-260128",
    "prompt": "电商主图,白底,一瓶护肤品,柔和布光",
    "size": "1024x1024"
}

response = requests.post(url, headers=headers, json=payload)
print(response.json()["data"][0]["url"])

响应示例

{
  "created": 1780000000,
  "data": [
    {
      "url": "https://example.com/generated.png"
    }
  ]
}