通过 AI 生成图像,支持 DALL·E 和 Stable Diffusion 模型。
response = client.images.generate(
model="dall-e-3",
prompt="一只穿着太空服的猫在月球上喝咖啡",
size="1024x1024",
quality="hd",
n=1
)
image_url = response.data[0].url
print(image_url)
| 参数 | 类型 | 说明 |
|---|---|---|
prompt | string | 图像描述,建议英文 |
model | string | dall-e-3 / stable-diffusion-xl |
size | string | 1024x1024 / 1024x1792 / 1792x1024 |
quality | string | standard / hd |
n | integer | 生成数量 1-4 |
style | string | vivid / natural |
response = client.images.edit(
model="dall-e-2",
image=open("original.png", "rb"),
mask=open("mask.png", "rb"),
prompt="在空白区域添加一只猫",
size="1024x1024"
)