Image Generation API
Generate images with GPT Image 2 / 2.5 — the Codex ImageGen skill and the OpenAI-compatible API reference.
When using the GetToken relay service, Codex cannot generate images directly through the built-in client ImageGen.
Built-in ImageGen needs a key that can connect directly to the OpenAI Images API. GetToken provides a relay service API key, and that key does not take over the direct ImageGen path inside Codex.
Image generation with the GetToken relay service must use the gettoken-imagegen Skill.
Install It
Open the Stable Image API console, choose macOS or Windows, copy the one-line install command, run it, and restart Codex.
Already installed? Run the same command again to update to the latest version. Your config and task history are preserved. You can also let Codex run <skill>/bin/<platform>/gettoken-imagegen update.
Requirement
When generating images in Codex, image generation tasks must be handled by gettoken-imagegen.
Do not use:
- Built-in Codex ImageGen
- Image generation paths that depend on an official OpenAI direct key
Use:
gettoken-imagegenSkill- GetToken API Key
- OpenAI-compatible Images API endpoint
Configure the Endpoint
The installer writes the image API key and stable image endpoint into the skill configuration. Do not expose the API key in source code, screenshots, or public commands after installation.
Install Location
The Skill is installed under ~/.agents/skills/gettoken-imagegen. Run the install command on the same machine where Codex runs.
Troubleshooting
Why not use built-in ImageGen directly
Built-in Codex ImageGen requires a key that can connect directly to the OpenAI Images API. When using the GetToken relay service, that direct path does not work, so gettoken-imagegen must handle image generation.
Codex Cannot Find the Skill
Confirm the Skill is installed under ~/.agents/skills/gettoken-imagegen, then restart Codex.
Windows Installation Does Not Work
Confirm that you use the PowerShell install command on native Windows.
Generation Fails
Check:
- The image API key is configured.
- You can reach the stable image endpoint.
- The output directory exists and is writable.
API Reference
The GetToken Image Generation API follows the OpenAI Images specification. It supports gpt-image-2, gpt-image-2.5-flare, and gpt-image-2.5-sunburst for text-to-image generation and image edits.
- Base URL:
https://api.gettoken.dev/image/v1(China-optimized:https://api.clawto.link/image/v1) - Endpoints:
POST /images/generations(text-to-image)POST /images/edits(image edits,multipart/form-data)
- Auth:
Authorization: Bearer <image API key>(image keys are managed separately) - Response: identical to the OpenAI spec — images are returned as
data[].b64_jsonwith ausagetoken summary;response_formatis alwaysb64_json
Text-to-image /images/generations
| Parameter | Type | Description |
|---|---|---|
prompt | string | Required. Text description of the image to generate. |
model | string | gpt-image-2 / gpt-image-2.5-flare / gpt-image-2.5-sunburst |
n | integer | Number of images to generate. Default 1. |
size | string | auto / 1024x1024 / 1536x1024 / 1024x1536 / 2048x2048 / 4096x4096 |
quality | string | auto / low / medium / high / xhigh / max |
background | string | auto / opaque / transparent. transparent requires PNG or WebP output. |
output_format | string | png / jpeg / webp |
output_compression | integer | 0-100, applies to jpeg / webp only. Lower means stronger compression. |
moderation | string | auto (default) / low. Controls moderation strictness. |
stream | boolean | Stream the result via server-sent events. |
partial_images | integer | 0-3. Number of partial previews in streaming mode. |
Image edits /images/edits
| Parameter | Type | Description |
|---|---|---|
image | file | Required. Image(s) to edit, uploaded via multipart/form-data. |
prompt | string | Required. Text description of the edit. |
mask | file | Optional. Mask whose transparent areas indicate where to edit. |
model | string | Same choices as above. |
n / size / quality / background / output_format / output_compression | - | Same meaning as text-to-image. |
input_fidelity | string | low (default) / high. high preserves details of the input image (faces, logos, etc.). |
stream / partial_images | - | Same meaning as text-to-image. |
Examples
Text-to-image:
curl https://api.clawto.link/image/v1/images/generations \
-H "Authorization: Bearer $IMAGE_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image-2.5-flare",
"prompt": "A clean product photo on a white desk",
"n": 1,
"size": "2048x2048",
"quality": "high",
"background": "auto",
"output_format": "png"
}'Image edit:
curl https://api.clawto.link/image/v1/images/edits \
-H "Authorization: Bearer $IMAGE_API_KEY" \
-F "model=gpt-image-2.5-flare" \
-F "prompt=Replace the background with a clean studio backdrop" \
-F "[email protected]" \
-F "input_fidelity=high" \
-F "size=2048x2048" \
-F "quality=high"Pricing (per image)
| Size tier | Billing boundary (longest edge) | Standard (USD) | Stable (USD) |
|---|---|---|---|
| 1K | <= 1024px | 0.134 | 1.5 |
| 2K | 1025-2048px | 0.201 | 3 |
| 4K | > 2048px | 0.268 | 4 |
Stable Image tiers are classified by the longest edge of the actual output size returned upstream; only when no recognizable size is returned does the requested
sizeapply.auto, empty, or unrecognized sizes fall back to 2K. The direct API passes customWxHthrough, but generation still depends on upstream support for that size.