Image and video API
Image models (GPT Image, Nano Banana) are billed for each image, and the price depends on the parameters. Look up the price and parameters of a specific model on its page in the catalog.
Generating an image
A request to POST /v1/images/generations:
curl https://api.codexkey.online/v1/images/generations \
-H "Authorization: Bearer sk_cdx_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "gpt-image-2", "prompt": "a red apple on a white table", "resolution": "1K", "size": "1024x1024"}'The link to the finished image arrives in data[].url. It is temporary, so save the file right away.
Parameters
| Parameter | What it sets |
|---|---|
model | Image model ID, for example gpt-image-2. |
prompt | The image description. |
resolution | Resolution, for example 1K, 2K or 4K. The price depends on it. Allowed values are listed on the model page. |
size | Image size, for example 1024x1024. |
tier | Applies to Nano Banana 2 only: the value lite turns on the lightweight mode. |
Editing from a reference
Editing from a reference goes through POST /v1/images/edits.
Nano Banana 2 lightweight mode
Nano Banana 2 can run in a lightweight mode, tier: "lite". The resolution parameter is not needed with it:
curl https://api.codexkey.online/v1/images/generations \
-H "Authorization: Bearer sk_cdx_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "nano-banana-2", "prompt": "a red apple on a white table", "tier": "lite"}'Cheap and Premium
GPT Image 2 (1K, 2K), GPT Image 2.5 and Nano Banana Pro are available in the Cheap channel as well: it is noticeably cheaper there, but generation fails more often. The channel is determined by the key's routing mode (see Premium and Cheap channels).
| Key mode | Image |
|---|---|
premium | Premium. |
cheap | Cheap. If generation is not possible right now, you get a 503 model_unavailable error and nothing is charged. |
auto_cheap, max | Cheap first, Premium on failure. |
auto_premium | Premium first, Cheap on failure. |
You pay at the rate of the channel that made the image; it is named in the channel field of the response (premium or cheap). Variants missing from Cheap (for example GPT Image 2 at 4K) and models without Cheap (video, Nano Banana 2) always go through Premium, even when the key is in cheap mode.
Cheap prices are listed in the Cheap catalog.
Video
Video is created as a task; the format is compatible with the OpenAI Videos API.
| Method | Path | What it does |
|---|---|---|
| POST | /v1/videos | Creates a task. |
| GET | /v1/videos/{id} | Shows the task status. |
| GET | /v1/videos/{id}/content | Returns the finished file. |
Create a task, poll its status using the identifier from the id field of the response, and download the file once the video is ready:
curl https://api.codexkey.online/v1/videos \
-H "Authorization: Bearer sk_cdx_YOUR_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "veo-3.1", "prompt": "a paper boat on a rainy street"}'
curl https://api.codexkey.online/v1/videos/VIDEO_ID \
-H "Authorization: Bearer sk_cdx_YOUR_KEY"
curl https://api.codexkey.online/v1/videos/VIDEO_ID/content \
-H "Authorization: Bearer sk_cdx_YOUR_KEY" \
-o video.mp4Billing
You are charged only for a successful result. See the error reference for error codes.