Skip to main content

GPT Image

POST /v1/images/generations
Use the gpt-image-1 model to generate images, compatible with the OpenAI Images API format.

Generate Image

Request Parameters

ParameterTypeRequiredDescription
modelstringYesFixed as gpt-image-1
promptstringYesImage description prompt
nintegerNoNumber of images to generate, default 1
sizestringNoImage size: 1024x1024 (default), 1536x1024, 1024x1536, auto
qualitystringNoQuality: auto (default), low, medium, high
backgroundstringNoBackground: auto (default), transparent, opaque
output_formatstringNoOutput format: png (default), jpeg, webp

Request Examples

curl -X POST https://crazyrouter.com/v1/images/generations \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -d '{
    "model": "gpt-image-1",
    "prompt": "A cat wearing a spacesuit walking on the moon with Earth in the background",
    "n": 1,
    "size": "1024x1024",
    "quality": "high"
  }'

Response Example

{
  "created": 1709123456,
  "data": [
    {
      "url": "https://crazyrouter.com/files/image_abc123.png",
      "revised_prompt": "A cat wearing a spacesuit walking on the moon's surface with Earth visible in the background"
    }
  ]
}

Edit Image

POST /v1/images/edits
Edit an existing image with mask-based region editing support.

Request Parameters

ParameterTypeRequiredDescription
modelstringYesFixed as gpt-image-1
imagefileYesOriginal image file (multipart)
promptstringYesEdit description
maskfileNoMask image, transparent areas indicate regions to edit
nintegerNoNumber of images to generate
sizestringNoOutput size

Request Example

Python
from openai import OpenAI

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

response = client.images.edit(
    model="gpt-image-1",
    image=open("original.png", "rb"),
    mask=open("mask.png", "rb"),
    prompt="Add a rainbow in the sky",
    n=1,
    size="1024x1024"
)

print(response.data[0].url)
GPT Image supports transparent background output. Set background: "transparent" and use PNG format.