Skip to main content
POST
https://www.geeknow.top
/
v1
/
images
/
generations
gpt-image-2 生成图像 API
curl --request POST \
  --url https://www.geeknow.top/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "prompt": "<string>",
  "n": 123,
  "size": "<string>",
  "image": [
    "<string>"
  ],
  "response_format": "<string>",
  "quality": "<string>",
  "style": {},
  "background": {},
  "watermark": true
}
'
{
  "created": 1735689600,
  "data": [
    {
      "url": "https://.../images/img-abc123.png",
      "revised_prompt": "一张现代 API 平台首页插图,白底,青蓝色块,干净留白"
    }
  ]
}

Documentation Index

Fetch the complete documentation index at: https://docs.geeknow.top/llms.txt

Use this file to discover all available pages before exploring further.

gpt-image-2 生成图像 API

gpt-image-2 使用统一图像生成入口,适合按基础比例和尺寸档位发起文生图请求。
  • 统一入口为 POST /v1/images/generations
  • 通过 model = "gpt-image-2" 选择目标模型。
  • 支持 urlb64_json 两种返回格式。
  • 可在 JSON 中附带 image 作为参考图,是否生效取决于实际命中的图像渠道。
  • n 不传或显式传 0 时,统一层会回退为 1

方法与路径

POST /v1/images/generations

请求示例

curl -X POST https://www.geeknow.top/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "一张现代 API 平台首页插图,白底,青蓝色块,干净留白",
    "n": 1,
    "size": "1536x1024",
    "response_format": "url"
  }'

响应示例

{
  "created": 1735689600,
  "data": [
    {
      "url": "https://.../images/img-abc123.png",
      "revised_prompt": "一张现代 API 平台首页插图,白底,青蓝色块,干净留白"
    }
  ]
}

认证

Authorization: Bearer YOUR_API_KEY

Body

model
string
required
固定传 gpt-image-2
prompt
string
生成提示词。对于文生图语义应视为必填。
n
integer
生成数量。若不传或显式传 0,统一层回退为 1
size
string
输出尺寸。常见基础档位为 1024x10241536x11521536x10241024x15361920x10801080x1920
image
string | array<string> | object
可选参考图输入。常见写法是 Base64 字符串或 Base64 数组,适合需要图像风格参考的渠道。
response_format
string
返回格式,常见值为 urlb64_json
quality
string
质量字段。是否真正生效取决于最终命中的渠道。
style
string | object
风格字段,原样透传给支持的上游。
background
string | object
背景控制字段,原样透传给支持的上游。
watermark
boolean
显式水印开关。false 与不传语义不同。

基础比例与尺寸档位

预设实际目标尺寸
1:11024x1024
4:31536x1152
3:21536x1024
2:31024x1536
16:91920x1080
9:161080x1920
如果实际渠道不原生接受目标尺寸,网关或插件会回退到更接近的官方尺寸,并把比例意图附加到 prompt。

Response

created
integer
生成时间戳。
data[].url
string
response_format = url 时返回的图片 URL。
data[].b64_json
string
response_format = b64_json 时返回的图片 Base64 数据。
data[].revised_prompt
string
部分上游会改写提示词并返回在这个字段里。

相关接口