newapi-image is a Codex skill for generating images through a user-provided OpenAI-compatible New API gateway. It uses the synchronous Images API by default and includes a small Python helper that can call:
/v1/images/generations(default)/v1/images/generations/async- Responses API with the
image_generationtool (explicit legacy mode)
The skill is useful when you want Codex to test or use your own compatible gateway instead of Codex's built-in image generation tool.
Copy the skill folder into your Codex skills directory:
Copy-Item -Recurse -LiteralPath .\newapi-image -Destination "$HOME\.codex\skills\newapi-image"Restart Codex so the new skill metadata is discovered.
Put your API key in ~/.codex/auth.json:
{
"NEWAPI_API_KEY": "your-api-key"
}Optionally set a custom gateway base URL in ~/.codex/config.toml:
[model_providers.custom]
base_url = "https://your-gateway.example/v1"The script also accepts command-line overrides:
python .\newapi-image\scripts\generate_image.py `
--base-url "https://your-gateway.example/v1" `
--model "gpt-image-2" `
--prompt "a glass lucky cat on a futuristic desk, realistic photo" `
--output ".\image.png"The command sends POST https://your-gateway.example/v1/images/generations. Use --async-mode only when the gateway supports the async sidecar. The old Responses image path remains available only through --responses-mode.
Do not commit real API keys. The script reads credentials from Codex auth config or from the --api-key argument for temporary local testing.
MIT