Skip to content
Sign Up Free
Codex

Edit and generate images in Codex with BetterToken Image Gen

Install BetterToken Image Gen, store your API key locally, and edit project images or generate new ones without changing your Codex chat model.

Use BetterToken Image Gen even when a third-party API powers your Codex chat and the built-in image tool is unavailable. The skill calls the BetterToken Images API without changing your login or chat model. Installation and key setup make no image requests. Each generation or edit produces one image and is billed by BetterToken.

Install the skill and set up your key

Open a project in the local Codex app or Codex CLI. Have your BetterToken API Key ready and send this message to Codex:

Use skill-installer to install skills/bettertoken-image-gen from https://github.com/RealBetterToken/bettertoken-image-gen in my personal skills directory. Preserve any local changes if it is already installed. Check for Node.js 20 or later and npm.
In the installed skill directory, run npm ci --ignore-scripts --no-audit --no-fund, then node scripts/image.mjs --setup-key. Wait for me to enter my BetterToken API Key in the local password dialog. Do not ask for it in chat. Run node scripts/image.mjs --help to check the installation without generating an image.

Enter the key only in the local password dialog, never in chat, command arguments, or project files. macOS uses Keychain; Windows uses Credential Manager. On a Linux desktop, install Zenity for the dialog and enable Secret Service to keep the key across restarts.

Edit an image in your project

Place an image in your project, for example product.png. Reopen Codex and start a new chat. Replace the input filename below if yours differs.

$bettertoken-image-gen Change only the background of product.png to warm white. Keep the product outline, colors and packaging text. Save as output/product-warm.png and show the result. Keep the original file.

Open output/product-warm.png to check the result. Use that file as input for the next edit. For multiple references, describe each image’s role. For a masked edit, supply a PNG mask matching the first input’s dimensions. Transparent areas mark the region to edit.

Generate an image without a source file

$bettertoken-image-gen Generate a 1024x1024 product photo of a green ceramic mug on a light wood table in natural light. No text. Save it as output/mug.png.

The default image model is gpt-image-2.6-flare. To use gpt-image-2.6-sunburst or gpt-image-2, name it in your prompt. Check current prices in the model plaza.

Troubleshooting

Skill missing or the built-in tool opens: Check that the installed directory contains SKILL.md. Restart Codex and begin your prompt with $bettertoken-image-gen in a new chat. The old community skill’s configuration is separate; leave it in place.

Invalid key or key rotation: Ask Codex to change your BetterToken Image Gen API key and enter it in the new dialog. If set, BETTERTOKEN_API_KEY overrides the saved key. Update or unset it in the environment that starts Codex.

Missing input or timeout: Give Codex a readable local image path. Allow network access to BetterToken when prompted. If a request times out after submission, check BetterToken usage before retrying to avoid a duplicate charge.