Routes to OpenAI's image generation models. Bills per token and supports streaming partial images and image-to-image with mask editing.
Basic generation
curl -X POST https://51kik.com/v1/image/v1/generations \
-H 'Authorization: Bearer sk-xxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-image-1",
"prompt": "isometric pixel-art spaceship launching",
"size": "1024x1024",
"upstream_options": { "quality": "high", "output_format": "png", "background": "auto" }
}'
Billing
GPT Image bills per token. Usage structure:
{
"usage": {
"input_tokens": { "image_tokens": 0, "text_tokens": 32 },
"output_tokens": { "image_tokens": 4096, "text_tokens": 0 },
"total_tokens": 4128
}
}
Image-to-image + mask editing
curl -X POST https://51kik.com/v1/image/v1/generations \
-H 'Authorization: Bearer sk-xxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-image-1",
"prompt": "remove the background",
"image": "https://example.com/source.png",
"size": "1024x1024",
"upstream_options": { "quality": "high", "background": "transparent", "output_format": "png", "input_fidelity": "high", "mask": "https://example.com/mask.png" }
}'
Streaming (partial images)
curl -N -X POST https://51kik.com/v1/image/v1/generations \
-H 'Authorization: Bearer sk-xxxxxxxx' \
-H 'Content-Type: application/json' \
-d '{
"model": "gpt-image-1",
"prompt": "watercolor cathedral at golden hour",
"size": "1024x1024",
"stream": true,
"upstream_options": { "partial_images": 3, "output_format": "png" }
}'
Common upstream_options
| Parameter | Description |
|---|---|
quality | Quality: low / medium / high |
output_format | png / webp / jpeg |
background | Background color / transparent |
n | Number of images |
mask | Edit mask URL |
partial_images | Number of partial frames in streaming |
input_fidelity | Reference image fidelity |