图像生成 (Images Generations)
图像生成接口用于根据一段文本提示词(Prompt)生成全新的图像(文生图)。它兼容 OpenAI 的 DALL-E 系列模型。
POST /v1/images/generations| 参数 | 类型 | 必填 | 默认值 | 说明 |
|---|---|---|---|---|
model | string | ❌ | dall-e-2 | 调用的绘图模型 ID(例如 dall-e-3, flux-schnell)。 |
prompt | string | ✅ | - | 生成图像的文本描述。长度通常有一定限制(例如 DALL-E 3 为 4000 字符)。 |
n | integer | ❌ | 1 | 生成的图像数量。对于 DALL-E 3,通常固定为 1。 |
size | string | ❌ | 1024x1024 | 图像分辨率。例如 1024x1024, 1024x1792。 |
response_format | string | ❌ | url | 返回的格式。支持返回图片直链 url,或图片 Base64 编码的 b64_json。 |
cURL 请求
Section titled “cURL 请求”curl https://api.easytakeai.com/v1/images/generations \ -H "Content-Type: application/json" \ -H "Authorization: Bearer YOUR_API_KEY" \ -d '{ "model": "dall-e-3", "prompt": "一只穿着宇航服在太空行走的金色寻回犬,写实风格,电影感光效", "size": "1024x1024", "n": 1 }'JSON 响应示例
Section titled “JSON 响应示例”{ "created": 1716298520, "data": [ { "url": "https://api.easytakeai.com/assets/images/generated-img-12345.png", "revised_prompt": "A golden retriever wearing a detailed astronaut suit, floating gracefully in deep space..." } ]}