GPT Image 2 API
Endpoints and authentication
TeamoRouter uses the OpenAI Images API compatible format:
- Generate images:
POST https://api.teamorouter.com/v1/images/generations - Edit images:
POST https://api.teamorouter.com/v1/images/edits
Request headers:
Authorization: Bearer sk-teamo-xxxxxx
Content-Type: application/json
The edit endpoint also accepts multipart/form-data for uploading image files.
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 tabby cat typing on a keyboard, illustration style"
}'
Specify size and quality:
{
"model": "gpt-image-2",
"prompt": "An orange tabby cat typing on a keyboard, illustration style",
"size": "2048x2048",
"quality": "high"
}
Common parameters:
| Parameter | Description |
|---|---|
model |
Use gpt-image-2. |
prompt |
Description of the image to generate. |
size |
auto or widthxheight, for example 1024x1024, 2048x2048, 3840x2160. |
quality |
low, medium, high, or auto. |
n |
Number of images to generate per request. Defaults to 1. |
output_format |
png, jpeg, or webp. |
output_compression |
JPEG/WebP compression level, 0 to 100. |
background |
transparent, opaque, or auto. With transparent, the returned image has an alpha channel; pair it with output_format set to png or webp. |
moderation |
Content moderation strictness, low or auto. |
stream |
Set to true to stream the response over SSE: intermediate chunks have object set to image.generation.chunk, the final chunk has object set to image.generation.result with the result image in data[0].b64_json, followed by data: [DONE]. |
partial_images |
0 to 3. Currently intermediate chunks carry no image; only the final chunk carries the result. |
user |
A caller-defined end-user identifier, passed through as is. |
OpenAI's size constraints for gpt-image-2: the longest side must not exceed 3840 pixels; width and height must both be multiples of 16; the aspect ratio must not exceed 3:1; and the total pixel count must be between 655,360 and 8,294,400. Sizes are pixel dimensions, not fixed 1k, 2k, 4k strings.
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"
Common parameters:
| Parameter | Description |
|---|---|
model |
Use gpt-image-2. |
image |
The source image file. |
mask |
Mask image file; transparent areas are editable. Must match the source image size. |
prompt |
The edit instruction. |
n |
Number of images to generate per request. Defaults to 1. |
size |
auto or widthxheight. |
quality |
low, medium, high, or auto. |
background |
transparent, opaque, or auto. In testing, images returned by the edit endpoint do not carry an alpha channel. |
input_fidelity |
How faithfully to preserve details of the source image, high or low. |
output_format |
png, jpeg, or webp. |
output_compression |
JPEG/WebP compression level, 0 to 100. |
stream |
Set to true to stream the response over SSE. The event format depends on the upstream channel: in most cases it matches image generation; it may also be OpenAI-native events that end with event: image_generation.completed, with the result image in that event's b64_json. |
partial_images |
0 to 3. |
user |
A caller-defined end-user identifier, passed through as is. |
Size and billing rules
Image generation is billed per image. Each image's unit price is determined by its actual resolution, in three tiers by the longest side:
| Longest side of the output image | Tier |
|---|---|
| Up to 1024 | 1K |
| Up to 2048 | 2K |
| Above 2048 | 4K |
The tier is decided by the actual width and height of the returned image, not by the request parameters. When size is auto, omitted, or empty, billing follows the size the model actually outputs; without size, the model outputs 1024 or 1254 pixels by default, billed as 1K or 2K respectively. Pass size explicitly if you need a fixed tier. See live pricing for the three tier prices.