Lightweight OpenAI-compatible image generation & editing proxy (/v1/images/generations & /v1/images/edits) with multi-account OAuth rotation and a password-protected Management Web UI.
- Drop-In OpenAI Images API: Works with any OpenAI SDK or client supporting
/v1/images/generationsand multipart/v1/images/edits(up to 5 reference images, 10 MB each). - Multi-Account OAuth Pool: Automatically rotates across multiple ChatGPT/Codex OAuth accounts with built-in cooldown handling on rate limits.
- Browser Management UI (
/management): View pool health, generate manual PKCE OAuth login links, importauth.json, or harvest mounted credentials—all behind a signedHttpOnlysession cookie. - Hardened Docker & Portainer Ready: Runs as non-root (
node, UID1000), supports read-only root filesystem, and keeps all credentials strictly in a persistent/datavolume.
Prerequisite: Docker / Docker Compose or Portainer.
Create .env.docker from .env.docker.example and set strong random values for PROXY_API_KEY, MANAGEMENT_PASSWORD, and MANAGEMENT_SESSION_SECRET:
cp .env.docker.example .env.docker
docker pull ghcr.io/ngojclee/codex-imagegen:latest
docker run -d --name codex-imagegen \
-p 3456:3456 \
--env-file .env.docker \
--read-only \
--tmpfs /tmp \
--security-opt no-new-privileges:true \
-v /path/to/codex-imagegen/data:/data \
ghcr.io/ngojclee/codex-imagegen:latest(For Portainer, paste deploy/portainer-stack.yml and deploy/portainer.env.example, and ensure the host data folder is owned by UID 1000 with chmod 700.)
- Open
http://<your-host>:3456/managementand sign in withMANAGEMENT_PASSWORD. - Click Create Login Link, sign in via your browser, and copy the full callback URL (
code=...&state=...) from the address bar (it is normal for the callback page itself to show connection refused). - Paste the callback URL into Callback URL and click Complete Login (or paste an existing
auth.jsonin Import Auth).
# Text-to-image
curl -X POST http://<your-host>:3456/v1/images/generations \
-H "Authorization: Bearer <PROXY_API_KEY>" \
-H "Content-Type: application/json" \
-d '{"prompt":"a cinematic fantasy city at sunrise"}'
# Image edits (multipart)
curl -X POST http://<your-host>:3456/v1/images/edits \
-H "Authorization: Bearer <PROXY_API_KEY>" \
-F "prompt=Apply the style from the first image onto the second" \
-F "image[]=@source.png;type=image/png" \
-F "image[]=@target.png;type=image/png"- Strong Secret Separation: Set unique values for
PROXY_API_KEY,MANAGEMENT_PASSWORD, andMANAGEMENT_SESSION_SECRET; keepADMIN_API_KEYempty unless you explicitly need/admin/*automation. - Session & CSRF Protection: Management UI uses
HttpOnlysigned cookies and requiresx-codex-imagegen-csrf: 1on mutating requests. - Protect
/management&/data: Place/managementbehind VPN, Tailscale, Cloudflare Access, or an HTTPS reverse proxy, and never commit.envor/data(which stores OAuth refresh tokens).
Advanced & Developer Reference (API Fields, Admin Endpoints, Environment Variables & Troubleshooting)
GET /health— Health checkGET /management— Browser Management UIPOST /v1/images/generations— JSON fields:prompt(required),model,input_refs,timeout_ms,size,quality,background,nPOST /v1/images/edits— Multipart fields:prompt,image[]/image(max 5 files, 10 MB each)- Optional Admin API (requires
ADMIN_API_KEY):GET /admin/accounts,POST /admin/harvest,POST /admin/accounts/:id/revive,DELETE /admin/accounts/:id
| Variable | Default | Notes |
|---|---|---|
PROXY_API_KEY |
(required in Docker) | Bearer token for /v1/images/* |
MANAGEMENT_PASSWORD |
(empty = disabled) | Password for /management UI |
MANAGEMENT_SESSION_SECRET |
(required with UI) | HMAC secret for signed session cookies |
MANAGEMENT_COOKIE_SECURE |
false |
Set true behind HTTPS |
ADMIN_API_KEY |
(empty = disabled) | Enables /admin/* endpoints |
PORT |
3456 |
Container listen port |
DEFAULT_MODEL |
gpt-5.4 |
Default upstream model |
DEFAULT_TIMEOUT_MS |
900000 |
Request timeout |
COOLDOWN_DEFAULT_MS |
60000 |
Account cooldown after 429/403 |
OAUTH_REDIRECT_URI |
http://localhost:1455/auth/callback |
Manual PKCE OAuth redirect URI |
npm install
npm startunauthorizedpulling GHCR image: Authenticateghcr.iowith a GitHub PAT havingread:packages(or make the GHCR package public).- Container cannot write to
/data: Ensurechown -R 1000:1000 <data-dir> && chmod 700 <data-dir>. /managementsays disabled: SetMANAGEMENT_PASSWORDand redeploy.
Licensed under the MIT License.