跳转到主要内容

Documentation Index

Fetch the complete documentation index at: https://docs.crazyrouter.com/llms.txt

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

GPT Image

gpt-image-2 通过 OpenAI Images API 兼容路径调用:
POST /v1/images/generations
POST /v1/images/edits
gpt-image-2 图片生成请求请优先使用主承接线路 https://cn.crazyrouter.com/v1。完整生成端点为 https://cn.crazyrouter.com/v1/images/generations。账号登录、充值和控制台仍使用 https://crazyrouter.com

生成图像

请求参数

参数类型必填说明
modelstring固定为 gpt-image-2
promptstring图像描述提示词
ninteger生成数量,默认 1,范围 1-10
sizestringauto宽x高。宽高必须为 16 的倍数,单边不超过 3840,总像素在 655360 到 8294400 之间,长短边比例不超过 3:1。常用值:1024x10241536x10241024x1536
qualitystringautolowmediumhigh。兼容 hd,服务端会归一为 high;不接受 standard
backgroundstringautoopaquegpt-image-2 不支持 transparent
output_formatstringpngjpegwebp
output_compressioninteger0-100,仅当 output_formatjpegwebp 时可用
moderationstringautolow
streamboolean是否使用 SSE 流式响应
partial_imagesinteger0-3,仅当 stream=true 时可用
userstring终端用户标识
以下参数不会被 gpt-image-2 接受:response_formatstyleinput_fidelitybackground=transparentquality=standardoutput_format=png 搭配 output_compression
response_format 不是 gpt-image-2 参数。不要传 response_format="url"response_format="b64_json";请用 output_format="png""jpeg""webp" 控制图片文件格式,并默认读取响应里的 data[0].url。DALL-E、Doubao、Qwen 等其他图片模型页面中的 response_format 说明不适用于 gpt-image-2

请求示例

curl -X POST https://cn.crazyrouter.com/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "一只穿着宇航服的猫咪在月球上行走,背景是地球",
    "n": 1,
    "size": "1024x1024",
    "quality": "low",
    "output_format": "png"
  }'

流式生成

gpt-image-2 支持 stream=true。如果请求中包含 partial_images,必须同时开启 stream,且取值范围为 0-3
cURL
curl -N -X POST https://cn.crazyrouter.com/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "一个蓝色极简验证图标,白色背景",
    "size": "1024x1024",
    "quality": "high",
    "stream": true,
    "partial_images": 2
  }'
quality=high 或兼容写法 quality=hd 的同步请求可能耗时较长。图片生成业务请优先走 https://cn.crazyrouter.com/v1;高质量请求建议使用 stream=true,或确保客户端超时大于 180 秒。

响应示例

{
  "created": 1778990000,
  "data": [
    {
      "url": "https://media.crazyrouter.com/task-artifacts/2026/05/17/sync-image/request-id-1.png"
    }
  ],
  "output_format": "png",
  "quality": "low",
  "size": "1024x1024"
}

编辑图像

POST /v1/images/edits
基于已有图像进行编辑,支持遮罩区域编辑,也支持传入多张参考图做融合、风格迁移或局部组合。

请求参数

参数类型必填说明
modelstring固定为 gpt-image-2
image / image[]file 或 file[]原始图片或参考图片文件(multipart);gpt-image-2 最多支持 16 张参考图
promptstring编辑描述
maskfile遮罩图片,透明区域为需要编辑的部分
ninteger生成数量,默认 1,范围 1-10
sizestring同生成接口
qualitystringautolowmediumhighhd 会归一为 high
backgroundstringautoopaque
output_formatstringpngjpegwebp
output_compressioninteger0-100,仅当 output_formatjpegwebp 时可用
streamboolean是否使用 SSE 流式响应
partial_imagesinteger0-3,仅当 stream=true 时可用

单图编辑示例

Python
from openai import OpenAI

client = OpenAI(
    api_key="YOUR_API_KEY",
    base_url="https://cn.crazyrouter.com/v1",
)

response = client.images.edit(
    model="gpt-image-2",
    image=open("original.png", "rb"),
    mask=open("mask.png", "rb"),
    prompt="在天空中添加一道彩虹",
    n=1,
    size="1024x1024",
    quality="low",
)

print(response.data[0].url)

多图参考编辑示例

多图编辑请求必须使用 multipart/form-data。推荐用多个 image[] 字段传参考图;服务端也兼容重复的 image 字段。
curl -X POST https://cn.crazyrouter.com/v1/images/edits \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "model=gpt-image-2" \
  -F "prompt=把第一张图的人物与第二张图的背景融合成一张自然的宣传图" \
  -F "size=1024x1024" \
  -F "quality=low" \
  -F "n=1" \
  -F "image[]=@person.png" \
  -F "image[]=@background.png"
gpt-image-2 多图参考最多支持 16 张图片。多图请求会优先路由到支持多图参考的官方 OpenAI 承载渠道。