Skip to content

GPT Image 2

Model Introduction

gpt-image-2 is an OpenAI-compatible image model available through Exchange Token. It supports both text-to-image generation and image editing with the same gateway authentication pattern used by the rest of the OpenAI-compatible models.

OpenAI-Compatible Image API

Use the standard Exchange Token gateway address and keep the request format aligned with OpenAI Images API:

  • Image generation: POST /v1/images/generations
  • Image editing: POST /v1/images/edits

Calling Method

API Endpoint

text
https://api.exchangetoken.ai/v1

Authentication

All requests must include:

text
Authorization: Bearer YOUR_API_KEY

Supported Model Name

  • gpt-image-2

Image Generation

Request Path

text
POST /v1/images/generations

Request Format

  • Content-Type: application/json
  • Put model in the JSON body

Example

bash
curl -X POST "https://api.exchangetoken.ai/v1/images/generations" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-image-2",
    "prompt": "A cute cat sitting on a windowsill, realistic photo, soft morning light",
    "n": 1,
    "size": "1024x1024",
    "quality": "high"
  }'

Image Editing

Request Path

text
POST /v1/images/edits

Request Format

  • Content-Type: multipart/form-data
  • Put model in the form fields
  • image or repeated image[] fields are required
  • mask is optional

Single-Image Example

bash
curl -X POST "https://api.exchangetoken.ai/v1/images/edits" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "model=gpt-image-2" \
  -F "image=@input.png" \
  -F "prompt=Add a vivid green background behind the cat" \
  -F "mask=@mask.png"

Multi-Image Example

bash
curl -X POST "https://api.exchangetoken.ai/v1/images/edits" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -F "model=gpt-image-2" \
  -F "image[]=@body-lotion.png" \
  -F "image[]=@bath-bomb.png" \
  -F "image[]=@incense-kit.png" \
  -F "image[]=@soap.png" \
  -F 'prompt=Create a lovely gift basket with these four items in it'

Common Parameters

ParameterLocationRequiredDescription
modelJSON / form-dataYesUse gpt-image-2
promptJSON / form-dataYesText instruction for generation or editing
image / image[]form-dataRequired for editsInput image file, or repeated image[] fields for multi-image editing
maskform-dataNoOptional transparent mask for edit region
nJSONNoNumber of images to generate
sizeJSONNoImage size, such as 1024x1024
qualityJSON / form-dataNoOutput quality, such as low, medium, or high

Notes

  • The downstream interface remains OpenAI-style. Users do not need to care about upstream Azure deployment paths or API versions.
  • For image edits, multipart/form-data should be used instead of JSON.
  • For multi-image edits, send multiple files with repeated image[] form fields.
  • When using the OpenAI SDK, keep base_url pointed at https://api.exchangetoken.ai/v1 and switch only the path and model name.