GPT Image 2 API Guide
1. Endpoint and authentication
TeamoRouter uses an OpenAI Images API-compatible format:
- Image generation:
POST https://api.teamorouter.com/v1/images/generations - Image editing:
POST https://api.teamorouter.com/v1/images/edits
Send your API key in the request headers:
Authorization: Bearer sk-teamo-xxxxxx
Content-Type: application/json
The editing endpoint also accepts multipart/form-data for uploading image files.
2. Generate images
Minimal request
curl https://api.teamorouter.com/v1/images/generations \
-H "Authorization: Bearer sk-teamo-xxxxxx" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2",
"prompt": "An orange cat typing on a keyboard, illustration style"
}'
Specify size and quality
{
"model": "gpt-image-2",
"prompt": "An orange cat typing on a keyboard, illustration style",
"size": "2048x2048",
"quality": "high"
}
Common parameters
| Parameter | Description |
|---|---|
model |
Use gpt-image-2. TeamoRouter uses this model by default when omitted. |
prompt |
Description of the image to generate. |
size |
auto or width x height, such as 1024x1024, 2048x2048, or 3840x2160. |
quality |
low, medium, high, or auto. |
n |
Number of images to generate, default 1. |
output_format |
png, jpeg, or webp. |
output_compression |
JPEG/WebP compression level from 0 to 100. |
OpenAI's constraints for gpt-image-2 are: the longest edge must not exceed 3840 pixels; both dimensions must be multiples of 16; the aspect ratio must not exceed 3:1; and total pixels must be between 655,360 and 8,294,400. Sizes are pixel dimensions, not fixed 1k, 2k, or 4k strings.
3. Edit images
curl https://api.teamorouter.com/v1/images/edits \
-H "Authorization: Bearer sk-teamo-xxxxxx" \
-F "model=gpt-image-2" \
-F "prompt=Replace the background with snowy mountains" \
-F "image=@input.png" \
-F "size=1024x1024"
4. TeamoRouter size-based routing
TeamoRouter reads the size field from the request body and selects the image generation route based on the requested dimensions:
| Request body | Selected route |
|---|---|
No size parameter |
Default 1K generation route |
Either dimension equals 1024, such as 1024x1024, 1024x1536, or 1536x1024 |
1K generation route |
size is present and contains no 1024, such as 2048x2048, 2048x1152, or 3840x2160 |
Generation route for the requested dimensions |
“Contains 1024” means that either the requested width or height equals 1024. The decision is based on the request parameter, not the actual dimensions of the generated image file.
Examples:
No size -> Default 1K generation
1024x1024 -> 1K generation
1024x1536 -> 1K generation
1536x1024 -> 1K generation
2048x2048 -> Generation at the requested dimensions
2048x1152 -> Generation at the requested dimensions
3840x2160 -> Generation at the requested dimensions
size: "auto" is a valid value supported by OpenAI. TeamoRouter identifies the required dimensions automatically and defaults to the 4K generation route.