Перейти к основному содержанию

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 uses the OpenAI-compatible Images API:
POST /v1/images/generations
POST /v1/images/edits
Use the primary image route https://cn.crazyrouter.com/v1 for gpt-image-2. The full generation endpoint is https://cn.crazyrouter.com/v1/images/generations. Account login, billing, and the console remain on https://crazyrouter.com.

Generate Image

Request Parameters

ParameterTypeRequiredDescription
modelstringYesFixed as gpt-image-2
promptstringYesImage description prompt
nintegerNoNumber of images, default 1, range 1-10
sizestringNoauto or WxH. Dimensions must be multiples of 16, each side must be at most 3840, total pixels must be 655360 to 8294400, and the long:short side ratio must not exceed 3:1. Common values: 1024x1024, 1536x1024, 1024x1536
qualitystringNoauto, low, medium, high. hd is accepted for compatibility and normalized to high; standard is rejected
backgroundstringNoauto or opaque. transparent is not supported for gpt-image-2
output_formatstringNopng, jpeg, webp
output_compressionintegerNo0-100, only with output_format=jpeg or output_format=webp
moderationstringNoauto or low
streambooleanNoReturn an SSE stream
partial_imagesintegerNo0-3, only when stream=true
userstringNoEnd-user identifier
These parameters are rejected for gpt-image-2: response_format, style, input_fidelity, background=transparent, quality=standard, and output_format=png with output_compression.
response_format is not a gpt-image-2 parameter. Do not send response_format="url" or response_format="b64_json"; use output_format="png", "jpeg", or "webp" to choose the image file format, and read data[0].url from the response by default. response_format notes on DALL-E, Doubao, Qwen, or other image-model pages do not apply to gpt-image-2.

Request Examples

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": "A cat wearing a spacesuit walking on the moon with Earth in the background",
    "n": 1,
    "size": "1024x1024",
    "quality": "low",
    "output_format": "png"
  }'

Streaming

gpt-image-2 supports stream=true. If you send partial_images, you must also set stream=true, and the value must be 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": "A simple blue verification icon on a white background",
    "size": "1024x1024",
    "quality": "high",
    "stream": true,
    "partial_images": 2
  }'
Synchronous quality=high requests, including the compatibility value quality=hd, can take a long time. For image workloads, use https://cn.crazyrouter.com/v1; for high-quality jobs, prefer stream=true or set your client timeout above 180 seconds.

Response Example

{
  "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"
}

Edit Image

POST /v1/images/edits
Edit an existing image with mask-based region editing support. You can also pass multiple reference images for blending, style transfer, or composition work.

Request Parameters

ParameterTypeRequiredDescription
modelstringYesFixed as gpt-image-2
image / image[]file or file[]YesOriginal image or reference image file(s), sent as multipart; gpt-image-2 supports up to 16 reference images
promptstringYesEdit description
maskfileNoMask image; transparent areas indicate regions to edit
nintegerNoNumber of images, default 1, range 1-10
sizestringNoSame rules as generation
qualitystringNoauto, low, medium, high; hd is normalized to high
backgroundstringNoauto or opaque
output_formatstringNopng, jpeg, webp
output_compressionintegerNo0-100, only with output_format=jpeg or output_format=webp
streambooleanNoReturn an SSE stream
partial_imagesintegerNo0-3, only when stream=true

Single-Image Edit Example

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="Add a rainbow in the sky",
    n=1,
    size="1024x1024",
    quality="low",
)

print(response.data[0].url)

Multi-Reference Edit Example

Multi-image editing requests must use multipart/form-data. Prefer multiple image[] fields for reference images; repeated image fields are also accepted.
curl -X POST https://cn.crazyrouter.com/v1/images/edits \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "model=gpt-image-2" \
  -F "prompt=Blend the person from the first image with the background from the second image into one natural campaign visual" \
  -F "size=1024x1024" \
  -F "quality=low" \
  -F "n=1" \
  -F "image[]=@person.png" \
  -F "image[]=@background.png"
gpt-image-2 supports up to 16 reference images. Multi-image requests are routed to carriers that support multi-reference image editing.