Generate images
Two synchronous endpoints: POST /v1/images/generations for text to image and POST /v1/images/edits for image to image. The response arrives when generation completes; large images can take up to a couple of minutes, so keep client timeouts generous.
Text to image
curl https://api.tokport.io/v1/images/generations \
-H "Authorization: Bearer $TOKPORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-image-2","prompt":"a neon koi swimming through clouds, cinematic lighting","size":"1024x1024","n":1}'Request fields
Shown for gpt-image-2; sizes and extras differ per model, see each model's schema.
| Field | Type | Description |
|---|---|---|
| model* | string | Model id. Always "gpt-image-2". |
| prompt* | string | What to generate. Be concrete about subject, style, lighting and composition. |
| size | string (enum) | Output size as "WIDTHxHEIGHT" pixels.1024x10241536x10241024x1536autodefault: 1024x1024 |
| n | integer | Number of images to generate in one request. Each image is billed.default: 1range: 1–4 |
| response_format | string (enum) | Return hosted URLs (expire after a while) or inline base64 PNG data.urlb64_jsondefault: url |
| quality | string (enum) | Rendering quality tier. Higher tiers take longer.lowmediumhighautodefault: auto |
| background | string (enum) | Transparent backgrounds need output_format png or webp.autoopaquetransparentdefault: auto |
| output_format | string (enum) | Encoding of the returned image.pngjpegwebpdefault: png |
Image to image (edits)
Send the reference as a public URL or a data: URL in image and describe the change in prompt. JSON bodies are accepted; multipart form uploads also work for OpenAI-style clients.
curl https://api.tokport.io/v1/images/edits \
-H "Authorization: Bearer $TOKPORT_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model":"gpt-image-2","image":"https://example.com/reference.png","prompt":"put the product on a marble pedestal with soft studio lighting","size":"1024x1024","n":1}'| Field | Type | Description |
|---|---|---|
| model* | string | Model id. Always "gpt-image-2". |
| image* | string (url | data:) | Reference image as a public URL or a data: URL (PNG, JPEG or WebP, up to 8 MB). |
| prompt* | string | How the reference image should change. The model keeps what you do not mention. |
| size | string (enum) | Output size as "WIDTHxHEIGHT" pixels.1024x10241536x10241024x1536autodefault: 1024x1024 |
| n | integer | Number of images to generate in one request. Each image is billed.default: 1range: 1–4 |
| response_format | string (enum) | Return hosted URLs (expire after a while) or inline base64 PNG data.urlb64_jsondefault: url |
Response
{
"created": 1726400000,
"data": [
{
"url": "https://cdn.example.com/generated/abc.png",
"revised_prompt": "a neon koi swimming through clouds, cinematic lighting"
}
]
}Synchronous. `data[]` holds one entry per generated image with `url` (or `b64_json` when requested). The `X-Oneapi-Request-Id` response header identifies the request in your usage log.
Image models
- gpt-image-2Text to image · Image to image
- gpt-image-2.5-flareText to image · Image to image
- gpt-image-2.5-sunburstText to image · Image to image
- qwen-image-2-1-unrestrictedText to image · Image to image
- seedream-5-pro-unrestrictedText to image · Image to image
- novelai-v5-unrestrictedText to image
- novelai-v4-5-unrestrictedText to image
- gpt-image-2-hdText to image · Image to image
- nano-banana-2-1Text to image · Image to image
- nano-banana-3-proText to image · Image to image
- nano-banana-3-1-flashText to image · Image to image
- grok-image-2-0Text to image · Image to image
- seedream-5-proText to image
- qwen-image-v2Text to image
- qwen-image-v2-proText to image
- qwen-image-v3Text to image
- qwen-image-v3-proText to image
- wan27-imageText to image
- kling-3-0-imageText to image
- z-image-turbo-fastText to image
Sizes & ratios
The size parameter takes an explicit pixel string like "1024x1536". Standard sizes per aspect ratio are in the size reference; allowed values per model are listed in its schema.