Skip to main content
POST
/
v1
/
images
/
generations
GPT-Image 图像生成
curl --request POST \
  --url https://api.example.com/v1/images/generations \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "prompt": "<string>",
  "n": 123,
  "size": "<string>",
  "quality": "<string>",
  "response_format": "<string>",
  "style": {},
  "background": {},
  "watermark": true
}
'
{
  "created": 1735689600,
  "data": [
    {
      "url": "https://cdn.example.com/images/img-abc123.png",
      "revised_prompt": "一张极简风格的 API 平台首页插图,白色背景,蓝绿色点缀"
    }
  ]
}

Documentation Index

Fetch the complete documentation index at: https://mercury-eab3b728.mintlify.app/llms.txt

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

GPT-Image 图像生成

使用统一图像生成入口提交文生图请求,返回 OpenAI Images 风格响应。
  • 统一的图像生成接口,通过 model 选择不同图像模型。
  • 保持 OpenAI Images 响应结构:created + data[]
  • 支持 urlb64_json 两种返回格式。
  • dall-e-2dall-e-3 的尺寸限制由统一层直接校验。
  • 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-1",
    "prompt": "一张极简风格的 API 平台首页插图,白色背景,蓝绿色点缀",
    "n": 1,
    "size": "1024x1024",
    "quality": "auto",
    "response_format": "url"
  }'

响应示例

{
  "created": 1735689600,
  "data": [
    {
      "url": "https://cdn.example.com/images/img-abc123.png",
      "revised_prompt": "一张极简风格的 API 平台首页插图,白色背景,蓝绿色点缀"
    }
  ]
}

认证

Authorization: Bearer YOUR_API_KEY

Body

model
string
required
模型名称。统一层直接要求该字段存在。
prompt
string
生成提示词。对于图像生成语义应视为必填,最终是否拦截由统一层和上游共同决定。
n
integer
生成数量。若不传或显式传 0,统一层回退为 1
size
string
输出尺寸。dall-e-2 只接受 256x256512x5121024x1024dall-e-3 只接受 1024x10241024x17921792x1024
quality
string
图像质量。dall-e-3 默认补成 standardgpt-image-1 默认补成 auto
response_format
string
返回格式,常见值为 urlb64_json。当请求 b64_jsonbase64 时,统一层返回 Base64 图像数据。
style
string | object
风格字段,原样透传给支持的上游。
background
string | object
背景控制字段,原样透传给支持的上游。
watermark
boolean
显式水印开关。false 与不传语义不同:不传表示交给默认策略,传 false 表示明确关闭。

Response

created
integer
生成时间戳。
data[].url
string
response_format = url 时返回的图片 URL。
data[].b64_json
string
response_format = b64_json 时返回的图片 Base64 数据。
data[].revised_prompt
string
部分上游会改写提示词并返回在这个字段里。
metadata
object
附加元数据。是否存在取决于具体渠道。

使用场景

基础生图

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-1",
    "prompt": "生成一张简洁的产品海报"
  }'

高质量 DALL·E 3

curl -X POST https://www.geeknow.top/v1/images/generations \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type": "application/json" \
  -d '{
    "model": "dall-e-3",
    "prompt": "一张科幻城市夜景插画",
    "size": "1792x1024",
    "quality": "hd",
    "response_format": "url"
  }'

Base64 输出

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-1",
    "prompt": "生成一张简洁的图标集海报",
    "response_format": "b64_json"
  }'

注意事项

这个页面只描述统一入口的公共语义,不代表所有图像渠道都支持完全相同的字段。像 stylebackgroundwatermark 等字段是否真正生效,取决于最终命中的渠道。

相关接口