POST
/
images
/
generations
curl --request POST \
  --url https://geekai.co/api/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "model": "dall-e-3",
  "prompt": "画一只可爱的小猫",
  "negative_prompt": "<string>",
  "image": "<string>",
  "strength": 0.5,
  "size": "1024x1024",
  "aspect_ratio": "1:1",
  "n": 1,
  "quality": "hd",
  "style_preset": "3d-model",
  "response_format": "url",
  "output_format": "png",
  "retries": 0
}'
{
  "created": 123,
  "data": [
    {
      "url": "<string>",
      "revised_prompt": "<string>"
    }
  ]
}

注:你可以在模型广场筛选查看系统支持的画图模型列表,画图模型基础请求/响应参数结构兼容 OpenAI,同时扩展了一些新的参数来适配其他模型的功能,切换模型时只需修改对应的模型名称即可,若模型请求/响应参数和 OpenAI 不一致,极客智坊底层会自动转换对齐。 响应数据格式和 OpenAI 完全兼容。

不同AI平台的画图模型支持的尺寸不一样,具体支持的尺寸请参考下面的表格:

平台模型支持的尺寸
OpenAIDALL·E 3

1024x1024,1792x1024,1024x1792,默认是1024x1024

智谱清言CogView系列

1024x1024,768x1344,864x1152,1344x768, 1152x864,1440x720,720x1440,默认是1024x1024

GoogleImagen 3

无尺寸配置,支持宽高比:1:1、3:4、4:3、9:16、16:9, 默认1:1,HTTP调用只支持默认值。

阿里巴巴通义万相2.1系列

图像宽高边长的像素范围为:[768, 1440],单位像素。 可任意组合以设置不同的图像分辨率,最高可达200万像素。 默认值:1024*1024

可灵AIkling-v1系列

无尺寸配置,支持宽高比:16:9、9:16、1:1、4:3、3:4、3:2、2:3, 默认1:1

StabilityStable Image系列

图像宽高边长的像素范围为:[64, 16384],单位像素。 可任意组合以设置不同的图像分辨率,总像素数至少需要达到 4096 像素。

画图模型 API 调用示例可以参考这里:生成图像

请求/响应参数明细

Authorizations

Authorization
string
header
required

JWT认证token

Body

application/json
model
string
required

图片生成模型

Example:

"dall-e-3"

prompt
string
required

文本提示

Example:

"画一只可爱的小猫"

negative_prompt
string

反向提示词,用来描述不希望在画面中看到的内容,可以对画面进行限制

image
string

用于以图生图,支持图片URL/Base64编码,目前仅可灵AI支持该配置

strength
number
default:0.5

以图生图引用图片的影响强度,取值范围[0, 1],默认0.5

size
string

图片尺寸,不同模型设置不同,详见模型尺寸表

Example:

"1024x1024"

aspect_ratio
string

图片宽高比,不同模型设置不同,详见模型尺寸表

Example:

"1:1"

n
integer

图片数量,默认为1

Example:

1

quality
string
default:auto

图片质量,可灵AI支持 std、pro 两个配置,OpenAI/智谱清言支持 standard、hd 两个配置,GPT Image支持 auto/low/medium/high 四个配置项

Example:

"hd"

style_preset
string

风格预设,目前仅 stable image 支持该配置

Example:

"3d-model"

response_format
enum<string>
default:url

图片响应格式,支持 url/b64_json 两种格式,默认为url

Available options:
url,
b64_json
output_format
enum<string>
default:png

图片输出格式,支持 png/jpg/webp 三种格式,默认为png

Available options:
png,
jpg,
webp
retries
integer
default:0

自动重试次数,默认0,表示失败不重试

Example:

0

Response

200
application/json
成功响应
created
integer
required

创建时间戳

data
object[]
required

生成的图片列表