Mangogo 营业厅Mangogo 营业厅
首页API 参考Skills插件

POST /v1/images/generations

POST/v1/images/generations

文生图。

鉴权:Bearer Token

Content-Type:application/json

请求体

{  "model": "dall-e-3",  "prompt": "A white siamese cat sitting on a windowsill, watercolor style",  "n": 1,  "size": "1024x1024",  "quality": "standard",  "response_format": "url"}

请求字段

字段类型必填说明
modelstring是图像模型 ID
promptstring是图像描述
ninteger否生成数量,默认 1
sizestring否尺寸,如 1024x1024、1792x1024
qualitystring否画质,如 standard、hd
response_formatstring否url(默认)或 b64_json
stylestring否风格,如 vivid、natural

Agnes 图像模型示例(含参考图):

{  "model": "agnes-image-2.0-flash",  "prompt": "A sunset over the ocean, cinematic lighting",  "size": "1024x768",  "response_format": "url",  "extra_body": {    "response_format": "url"  },  "image": ["https://example.com/reference.jpg"]}

请求示例(curl)

curl https://www.yunsell.com/v1/images/generations \  -H "Authorization: Bearer sk-xxx" \  -H "Content-Type: application/json" \  -d '{    "model": "dall-e-3",    "prompt": "A white siamese cat sitting on a windowsill, watercolor style",    "n": 1,    "size": "1024x1024",    "quality": "standard",    "response_format": "url"  }'

响应体

HTTP 200

{  "created": 1712697600,  "data": [    {      "url": "https://cdn.example.com/generated/image_abc123.png",      "revised_prompt": "A white Siamese cat perched on a sunlit windowsill, rendered in soft watercolor style."    }  ],  "usage": {    "quota_type": 1,    "prompt_tokens": 0,    "completion_tokens": 0,    "total_tokens": 0,    "request_count": 1,    "quota": 5000  }}

response_format 为 b64_json 时:

{  "created": 1712697600,  "data": [    {      "b64_json": "iVBORw0KGgoAAAANSUhEUgAA..."    }  ]}

响应字段

字段类型说明
createdintegerUnix 时间戳(秒)
dataarray生成结果,长度等于请求中的 n
data[].urlstring图片 URL(response_format=url 时返回)
data[].b64_jsonstringBase64 编码图片(response_format=b64_json 时返回)
data[].revised_promptstring模型改写后的 prompt(部分模型返回)
usageobject计费信息,见 公共响应对象

url 与 b64_json 互斥,取决于请求中的 response_format。

失败响应

HTTP 400 等,格式见 标准错误。