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/v1Authentication
All requests must include:
text
Authorization: Bearer YOUR_API_KEYSupported Model Name
gpt-image-2
Image Generation
Request Path
text
POST /v1/images/generationsRequest Format
Content-Type: application/json- Put
modelin 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/editsRequest Format
Content-Type: multipart/form-data- Put
modelin the form fields imageor repeatedimage[]fields are requiredmaskis 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
| Parameter | Location | Required | Description |
|---|---|---|---|
model | JSON / form-data | Yes | Use gpt-image-2 |
prompt | JSON / form-data | Yes | Text instruction for generation or editing |
image / image[] | form-data | Required for edits | Input image file, or repeated image[] fields for multi-image editing |
mask | form-data | No | Optional transparent mask for edit region |
n | JSON | No | Number of images to generate |
size | JSON | No | Image size, such as 1024x1024 |
quality | JSON / form-data | No | Output 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-datashould be used instead of JSON. - For multi-image edits, send multiple files with repeated
image[]form fields. - When using the OpenAI SDK, keep
base_urlpointed athttps://api.exchangetoken.ai/v1and switch only the path and model name.
