Images API

Two endpoints: Generate (text → image) and Edit (image + text → image). Both responses follow the OpenAI standard shape data[0].b64_json.

Generate images

POST https://api.kineticrouter.com/v1/images/generations

With gpt-image-2

gen.py
import base64 from openai import OpenAI client = OpenAI(api_key="YOUR_KINETICROUTER_API_KEY", base_url="https://api.kineticrouter.com/v1") resp = client.images.generate( model="openai/gpt-image-2", prompt="A simple red apple on a white table", size="1024x1024", quality="low", output_format="png", ) with open("output.png", "wb") as f: f.write(base64.b64decode(resp.data[0].b64_json))

Sample output:

Red apple generated by gpt-image-2

Parameters

ParameterTypeRequiredDescription
modelstring✅openai/gpt-image-2
promptstring✅Natural-language description
qualitystring✅auto / low / medium / high. Quality does not affect the price for the gpt-image family (see Billing below)
nnumber—1–10, default 1
sizestring—auto (defaults to 1536x1024) or any WIDTHxHEIGHT — see “Supported sizes” below
output_formatstring—png / jpeg / webp
backgroundstring—opaque / auto. gpt-image-2 does not support transparent (it errors)
streamboolean—Default false

Supported sizes (gpt-image-2)

Sizes are not a fixed list — any WIDTHxHEIGHT works as long as it satisfies all of:

  • both width and height are multiples of 16;
  • each side is ≤ 3840;
  • the aspect ratio is between 1:3 and 3:1;
  • total pixels are between 655,360 and 8,294,400 (~0.64MP to ~8.3MP).

Common sizes: 1024x1024, 1536x1024, 1024x1536, 2048x2048, 2560x1440; 4K tier: 3840x2160, 2160x3840, 2880x2880.

1920x1080 is rejected (1080 is not a multiple of 16) — use 1920x1088 instead. Legacy DALL·E sizes such as 256x256 and 512x512 fall below the pixel floor and are also unavailable.

The 4K tier is experimental: a single image can take several minutes (set client timeouts to ≥600s), and the upstream occasionally fails mid-render — failed generations are not billed.

Billing reference prices

These image prices are from the August 30, 2026 catalog snapshot. They are reference values, not a quote for your account or confirmation that image generation and editing are available to your key.

Line itemkineticRouter snapshot price
Image output$4.50/M tokens
Text input (prompt)$0.75/M tokens
Reference image input (edits)$1.20/M tokens where reported and billed

Recorded output-only examples in that snapshot were $0.0316 for 1024 by 1024, $0.0247 for 1536 by 1024, $0.0600 for 3840 by 2160, and $0.1067 for 2880 by 2880. Actual request costs depend on the model, metered usage, and the price rule for your account.

Confirm image capability and pricing for your key before integrating. The console Playground currently supports text conversations. Review Usage for actual billed cost, including interrupted or failed requests; do not assume an error means no charge.

Response

{ "created": 1777385517, "data": [ { "b64_json": "<image Base64>", "index": 0 } ], "model": "openai/gpt-image-2", "size": "1024x1024", "quality": "low", "usage": { "input_tokens": 8, "input_tokens_details": { "text_tokens": 8 }, "output_tokens": 7024, "total_tokens": 7032 } }

usage is returned in official terms: input = the o200k token count of the prompt, output = the official formula applied to the actual output size at the high tier — identical to what is billed. Note the example’s quality is low yet output still meters 7,024 at the high tier (see Billing).

The image lives in data[0].b64_json — base64-decode and save it.

Edit images

POST https://api.kineticrouter.com/v1/images/edits

multipart/form-data — you must upload an image file.

Call

edit.py
import base64 from openai import OpenAI client = OpenAI(api_key="YOUR_KINETICROUTER_API_KEY", base_url="https://api.kineticrouter.com/v1") with open("apple.png", "rb") as f: resp = client.images.edit( model="openai/gpt-image-2", image=f, prompt="Change the apple to green while keeping everything else unchanged", size="auto", quality="low", ) with open("apple_edited.png", "wb") as out: out.write(base64.b64decode(resp.data[0].b64_json))

The image field takes a local file path (with the @ prefix in cURL), not a URL.

Before / after:

OriginalEdited
Original red appleEdited green apple

Parameters

ParameterTypeRequiredDescription
modelstring✅Recommended: openai/gpt-image-2
imagefile✅PNG / JPEG file
promptstring✅Edit instruction
qualitystring✅low / medium / high
nnumber—Default 1
sizestring—auto keeps the original size

Response

Same shape as generation:

{ "created": 1777385669, "data": [ { "b64_json": "<edited image Base64>", "index": 0 } ], "model": "openai/gpt-image-2", "size": "auto", "quality": "low", "usage": { "input_tokens": 10, "input_tokens_details": { "text_tokens": 10 }, "num_input_images": 1, "output_tokens": 5488, "total_tokens": 5498 } }

Same as generation, usage is returned in official terms. num_input_images is the input image count. Note: reference-image input tokens are not counted (OpenAI publishes no reproducible input-image formula — see Billing above), so input_tokens_details carries only text_tokens.

See supported models and pricing in the Model Catalog .