Skip to main content
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": "gpt-image-1",
  "prompt": "画一只可爱的小猫",
  "negative_prompt": "<string>",
  "image": "<string>",
  "strength": 0.5,
  "size": "1024x1024",
  "aspect_ratio": "1:1",
  "n": 1,
  "quality": "medium",
  "style_preset": "3d-model",
  "response_format": "url",
  "output_format": "png",
  "mask": "<string>",
  "watermark": false,
  "background": "auto",
  "extra_body": {
    "sequential_image_generation": "disabled",
    "sequential_image_generation_options": {
      "max_images": 15
    }
  },
  "async": false,
  "retries": 0
}
'
{
  "created": 123,
  "data": [
    {
      "url": "<string>",
      "b64_json": "aSDinaTvuI8gbWludGxpZnk=",
      "revised_prompt": "<string>"
    }
  ],
  "task_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
  "task_status": "running"
}
Note: For setting the image generation model name, refer to the System Supported Image Generation Models List, ```markdown currently supported image generation models are dall-e-3, cogview-3-flash (free), cogview-3-plus, and cogview-4. The request/response parameter structure is fully compatible with OpenAI. When switching models, you only need to modify the corresponding model name. If the model request/response parameters are inconsistent with OpenAI, GeekAI will automatically convert and align them at the underlying level. The response data format is fully compatible with OpenAI.
Different AI platforms support different image sizes for their image generation models. Please refer to the table below for the specific supported sizes:
PlatformModelSupported Sizes
OpenAIDALL·E 31024x1024, 1792x1024, 1024x1792 (default is 1024x1024)
ZhipuCogView Series1024x1024, 768x1344, 864x1152, 1344x768, 1152x864, 1440x720, 720x1440 (default is 1024x1024)

cURL Request Example

curl --location 'https://geekai.dev/api/v1/images/generations' \
--header 'Content-Type: application/json' \
--header 'Authorization: {YOUR_GEEKAI_API_KEY}' \
--data '{
    "model":"dall-e-3",
    "prompt":"Draw a cute kitten playing in the grass",
    "size": "1024x1024",
    "n":1
}'

Authorizations

Authorization
string
header
required

API认证token

Body

application/json
model
string
required

图片生成模型

Example:

"gpt-image-1"

prompt
string
required

文本提示

Example:

"画一只可爱的小猫"

negative_prompt
string

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

image

单张图片URL/Base64编码数据,仅支持图生图模型支持该配置

strength
number
default:0.5

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

size
string
default:1024x1024

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

aspect_ratio
string
default:1:1

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

n
integer
default:1

图片数量,默认为1

quality
string
default:medium

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

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
mask
string

图片遮罩,支持图片URL/Base64编码数据

watermark
boolean
default:false

是否添加AI生成水印,默认为false,仅部分模型支持

background
enum<string>
default:auto

背景透明度,目前仅 gpt-image-1 支持该配置

Available options:
transparent,
opaque,
auto
extra_body
object

额外参数配置项,以适配不同画图模型的多样化配置

async
boolean
default:false

是否异步生成,默认false,即同步等待图片生成成功后返回生成结果,如果异步需要通过调用图片获取接口获取生成结果

retries
integer
default:0

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

Response

成功响应

created
integer<unix-timestamp>
required

创建时间戳

data
object[]
required

生成的图片列表(仅在task_status=succeed时返回)

task_id
string<uuid>

图片生成任务ID

task_status
enum<string>

任务状态

Available options:
pending,
running,
succeed,
failed
Example:

"running"