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-imagegen Skill
  • 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:

  1. The image API key is configured.
  2. You can reach the stable image endpoint.
  3. 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_json with a usage token summary; response_format is always b64_json

Text-to-image /images/generations

ParameterTypeDescription
promptstringRequired. Text description of the image to generate.
modelstringgpt-image-2 / gpt-image-2.5-flare / gpt-image-2.5-sunburst
nintegerNumber of images to generate. Default 1.
sizestringauto / 1024x1024 / 1536x1024 / 1024x1536 / 2048x2048 / 4096x4096
qualitystringauto / low / medium / high / xhigh / max
backgroundstringauto / opaque / transparent. transparent requires PNG or WebP output.
output_formatstringpng / jpeg / webp
output_compressioninteger0-100, applies to jpeg / webp only. Lower means stronger compression.
moderationstringauto (default) / low. Controls moderation strictness.
streambooleanStream the result via server-sent events.
partial_imagesinteger0-3. Number of partial previews in streaming mode.

Image edits /images/edits

ParameterTypeDescription
imagefileRequired. Image(s) to edit, uploaded via multipart/form-data.
promptstringRequired. Text description of the edit.
maskfileOptional. Mask whose transparent areas indicate where to edit.
modelstringSame choices as above.
n / size / quality / background / output_format / output_compression-Same meaning as text-to-image.
input_fidelitystringlow (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 tierBilling boundary (longest edge)Standard (USD)Stable (USD)
1K<= 1024px0.1341.5
2K1025-2048px0.2013
4K> 2048px0.2684

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 size apply. auto, empty, or unrecognized sizes fall back to 2K. The direct API passes custom WxH through, but generation still depends on upstream support for that size.

On this page