Local Node.js server that signs in with Codex/ChatGPT OAuth and exposes a small image-generation API.
It mirrors the Codex browser-login shape and stores OAuth tokens in a local JSON file. Image generation uses the private Codex backend endpoint that codex-imagen prototyped:
POST https://chatgpt.com/backend-api/codex/responses
This is an experimental local tool, not an official OpenAI package.
- Node.js 20+
- A ChatGPT/Codex account that can use Codex image generation
- A browser on the same machine for the OAuth callback
cd /Users/tuyenhx/Workspace/cli/codex_image_server
npm startOpen the local UI:
http://localhost:1455
Click Sign in, complete OAuth, then use the prompt form or call the JSON API.
Codex's OAuth client expects the localhost callback on port 1455, so this server defaults to that port.
Check auth status:
curl -sS http://127.0.0.1:1455/api/auth/statusGenerate an image:
curl -sS http://127.0.0.1:1455/api/generate-image \
-H 'content-type: application/json' \
-d '{"prompt":"a small blue square app icon, no text"}'Generate with reference image URLs or data:image/... URLs:
curl -sS http://127.0.0.1:1455/api/generate-image \
-H 'content-type: application/json' \
-d '{
"prompt": "restyle Image #1 as a clean product icon, no text",
"image_urls": ["https://example.com/reference.png"]
}'The response includes generated file paths and local URLs:
{
"images": [
{
"path": "/absolute/path/out/codex-image-....png",
"url": "/generated/codex-image-....png"
}
]
}Defaults:
data/codex-auth.json
out/
Override paths:
CODEX_IMAGE_AUTH_PATH=/path/to/auth.json \
CODEX_IMAGE_OUT_DIR=/path/to/out \
npm startUseful environment variables:
PORT local server port, default 1455
HOST bind host, default 127.0.0.1
PUBLIC_BASE_URL external callback base URL, default http://localhost:<port>
CODEX_IMAGE_MODEL model slug, default gpt-5.4
CODEX_IMAGE_BASE_URL Codex backend base URL
CODEX_REFRESH_URL OAuth token refresh endpoint
MAX_JSON_BODY_MB request JSON limit, default 50
- Keep
data/codex-auth.jsonprivate. It contains OAuth tokens. - The server binds to
127.0.0.1by default. - Do not expose this server publicly without adding your own access control.
MIT