Skip to content

darkamenosa/codex-image-server

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

codex-image-server

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.

Requirements

  • Node.js 20+
  • A ChatGPT/Codex account that can use Codex image generation
  • A browser on the same machine for the OAuth callback

Run

cd /Users/tuyenhx/Workspace/cli/codex_image_server
npm start

Open 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.

API

Check auth status:

curl -sS http://127.0.0.1:1455/api/auth/status

Generate 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"
    }
  ]
}

Storage

Defaults:

data/codex-auth.json
out/

Override paths:

CODEX_IMAGE_AUTH_PATH=/path/to/auth.json \
CODEX_IMAGE_OUT_DIR=/path/to/out \
npm start

Useful 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

Security Notes

  • Keep data/codex-auth.json private. It contains OAuth tokens.
  • The server binds to 127.0.0.1 by default.
  • Do not expose this server publicly without adding your own access control.

License

MIT

About

Local Codex OAuth image generation server prototype

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors