POST /v1/images/generations
application/json
参数名 | 类型 | 必填 | 默认值 | 描述 | 示例值 |
---|---|---|---|---|---|
model | string | ✅ | - | 使用的模型名称,支持 dall-e-2、dall-e-3 或 gpt-image-1 | "openai/gpt-image-1" |
prompt | string | ✅ | - | 图像描述文本,最大长度:gpt-image-1为32000字符,dall-e-2为1000字符,dall-e-3为4000字符 | "一只可爱的小猫坐在花园里" |
n | integer | ❌ | 1 | 生成图像的数量,范围1-10。dall-e-3仅支持n=1 | 2 |
size | string | ❌ | auto | 图像尺寸。gpt-image-1支持:1024x1024、1536x1024、1024x1536、auto;dall-e-2支持:256x256、512x512、1024x1024;dall-e-3支持:1024x1024、1792x1024、1024x1792 | "1024x1024" |
quality | string | ❌ | auto | 图像质量。gpt-image-1支持:auto、high、medium、low;dall-e-3支持:hd、standard;dall-e-2仅支持:standard | "high" |
output_format | string | ❌ | png | 输出格式,仅gpt-image-1支持。可选:png、jpeg、webp | "png" |
background | string | ❌ | auto | 背景透明度,仅gpt-image-1支持。可选:transparent、opaque、auto。transparent时需要使用png或webp格式 | "transparent" |
moderation | string | ❌ | auto | 内容审核级别,仅gpt-image-1支持。可选:low(较少限制)、auto | "auto" |
output_compression | integer | ❌ | 100 | 压缩级别(0-100%),仅gpt-image-1的webp或jpeg格式支持 | 85 |
{
"model": "openai/gpt-image-1",
"prompt": "一只可爱的奶牛猫躺在阳光明媚的花园里,周围有五颜六色的花朵",
"n": 1,
"size": "1024x1024",
"quality": "high"
}
{
"model": "openai/gpt-image-1",
"prompt": "一幅抽象艺术画,色彩鲜艳,几何图形组合",
"n": 1,
"size": "1536x1024",
"quality": "high",
"output_format": "png",
"background": "transparent",
"moderation": "low"
}
{
"created": 1589478378,
"data": [
{
"b64_json": "iVBORw0KGgoAAAANSUhEUgAABAAAAAQACAIAAADwf7zUAAA..."
}
],
"usage": {
"input_tokens": 37,
"input_tokens_details": {
"image_tokens": 0,
"text_tokens": 37
},
"output_tokens": 4160,
"total_tokens": 4197
}
}