Codex Remote Proxy lets Codex stay signed into ChatGPT for remote-control features while sending the actual model traffic to your own OpenAI-compatible base_url and API key.
Published on npm:
npm install -g @cluic/codex-remote-proxyCodex splits request routing and authentication across two local files:
~/.codex/config.tomlcontrols the OpenAIbase_url~/.codex/auth.jsoncontrols theAuthorizationtoken
When Codex is signed into ChatGPT, requests may still carry tokens.access_token instead of the API key required by your upstream provider.
This project inserts a local proxy that:
- receives Codex requests on
127.0.0.1 - forwards them to the real upstream
- rewrites
Authorizationto the real upstream API key
The Node implementation is the recommended and most tested path for successful forwarding and conversations.
npm install -g @cluic/codex-remote-proxyThen run:
crp init
crp startnpx @cluic/codex-remote-proxy init
npx @cluic/codex-remote-proxy startIf you are running directly from the repository:
cd node
npm install
node bin/crp.mjs startAfter setup:
- Restart Codex Desktop
- Sign in with your ChatGPT account
- Use Codex normally
The CLI manages its own files under:
~/.codex-remote-proxy/
This directory is used for:
- runtime config
- managed state
- proxy logs
- optional local shim files
You do not have to pass base_url and api_key to crp start every time.
Recommended options:
Add an optional section like:
[codex_remote_proxy]
upstream_base_url = "https://your-upstream.example.com"
upstream_api_key = "sk-your-key"
capture_enabled = true
capture_db_path = "/Users/you/.codex-remote-proxy/traffic.sqlite3"Then later runs only need:
crp startcrp init
crp startcrp init stores the upstream configuration under:
~/.codex-remote-proxy/config.json
After that, later runs only need:
crp startexport CRP_UPSTREAM_BASE_URL="https://your-upstream.example.com"
export CRP_UPSTREAM_API_KEY="sk-your-key"
export CRP_CAPTURE_ENABLED="true"
export CRP_CAPTURE_DB_PATH="/Users/you/.codex-remote-proxy/traffic.sqlite3"
crp startcrp start resolves values in this order:
- CLI flags
- Environment variables
~/.codex/config.tomlunder[codex_remote_proxy]usingupstream_base_url,upstream_api_key,capture_enabled, andcapture_db_path- Saved config from
crp init - Interactive prompts
Request capture is optional and disabled by default.
When enabled, the proxy stores one SQLite row per proxied HTTP transaction under:
~/.codex-remote-proxy/traffic.sqlite3
or a custom path you provide with capture_db_path.
What is stored:
- full request headers after proxy rewrites
- full request body
- full response headers
- full response body
- SSE responses aggregated into one stored body
Sensitive headers such as Authorization, Cookie, Set-Cookie, and token-like header names are redacted before writing.
Enable capture at startup:
crp start --capture
crp start --capture --capture-db-path /Users/you/.codex-remote-proxy/custom-traffic.sqlite3Hot-toggle capture on a running managed proxy:
crp capture on
crp capture off
crp capture status --jsonYou can also edit ~/.codex-remote-proxy/node/proxy-config.json directly. Changes to capture.enabled hot-apply after the proxy validates the SQLite connection. Changes to capture.dbPath are detected, but require a restart before the new path is used.
Main commands:
-
crp checkInspect Codex config, auth mode, runtime availability, and managed service state -
crp startAccept upstream settings from CLI flags, environment variables,~/.codex/config.toml[codex_remote_proxy], or prompts; choose a free port, patch Codex, and start the proxy in the background by default -
crp initSave upstream settings and optional capture defaults once under~/.codex-remote-proxy/so latercrp startcalls do not require secrets again if you do not want to place them in~/.codex/config.toml -
crp installCompatibility alias forcrp start -
crp capture on|off|statusToggle SQLite request capture on a running managed proxy, or persist the preference for the next start if the proxy is not running -
crp statusShow managed service status and health. If the proxy is running but not managed by this CLI, it will try to detect that too -
crp stopStop the managed service -
crp guidePrint AI-oriented usage guidance
Machine-readable examples:
crp check --json
crp capture status --json
crp guide --json
crp status --jsonRecommended flow:
- Run
crp check --json - Read
recommendedImplementation - If Node dependencies are ready, prefer
node - Prefer existing
~/.codex/config.toml[codex_remote_proxy]withupstream_base_url,upstream_api_key,capture_enabled, andcapture_db_path, otherwise ask the user to runcrp initonce locally, or rely on environment variables already set outside the AI session - Run
crp start - Read
proxyUrl,pid, andhealthfrom the JSON result - Use
crp status --jsonfor later verification
Notes:
startmodifies~/.codex/config.tomland creates a backup- the managed proxy runs in the background by default
- managed state and logs live under
~/.codex-remote-proxy/ - request capture writes to SQLite only when enabled
- when running directly from this repository, install Node dependencies first
~/.codex/config.toml,crp init, or environment variables can keep secrets out of later AI interactions
-
node/The packaged npm implementation. -
node/RELEASING.mdRelease setup and automated npm publishing flow. -
README.zh-CN.mdChinese documentation
