Area
CLI; Authentication and account pool; Service lifecycle; Platform (Linux).
What are you trying to accomplish?
I need Codex CLI processes launched on a Linux server to reach an OpenCodex provider configured with:
[model_providers.opencodex]
base_url = "http://127.0.0.1:10100/v1"
env_key = "OPENCODEX_API_AUTH_TOKEN"
without depending on a wrapper installed at the same filesystem path as the Codex binary. The token must remain outside config.toml, and Codex upgrades must not silently remove the credential injection mechanism.
What prevents this today?
env_key tells Codex which process environment variable to read; it does not create that variable. OpenCodex's current solution, ocx codex-shim install, replaces the Codex launcher with a POSIX wrapper that reads the service token and exports OPENCODEX_API_AUTH_TOKEN.
Codex upgrades can replace that path with a symlink or a fresh binary. After that, codex exec fails before reaching the proxy:
ERROR: Missing environment variable: `OPENCODEX_API_AUTH_TOKEN`.
Validated on OpenCodex 2.33.0 and Codex CLI 0.149.1:
| Launch state |
Result |
| OpenCodex shim installed |
HTTP 200; turn.completed; request recorded in usage.jsonl |
| Direct symlink to the real Codex binary, env absent |
Immediate missing-variable error; no proxy request |
| Direct binary with token manually exported |
Works, confirming the missing environment is the only blocker |
The current workaround is to reinstall the shim after every Codex update or maintain an external cron that detects and repairs it.
What should OpenCodex do?
Provide and document a shim-independent credential injection mode while preserving the current secure default:
- A first-class Linux environment integration, such as
ocx codex-env install, that installs a user-scoped environment generator/drop-in and can be audited/uninstalled; or
- A provider credential-file directive supported by the Codex integration, allowing the launcher to read
/root/.opencodex/service-api-token without storing the secret in config.toml or inheriting it through a shell wrapper.
At minimum, ocx doctor should detect the invalid combination "provider uses env_key + environment variable absent + shim absent" and print an actionable repair command.
The behavior should be idempotent, never print the token, create files with restrictive permissions, and survive Codex upgrades.
Example usage or interface
# Proposed first-class alternative
ocx codex-env install --mode systemd-user
ocx codex-env status
ocx codex-env uninstall
# Expected diagnostic
ocx doctor
# ERROR: model_providers.opencodex uses env_key=OPENCODEX_API_AUTH_TOKEN,
# but the variable is unavailable and no credential injector is active.
# Run: ocx codex-env install
Before/after behavior:
# Current, after a Codex upgrade overwrites the shim
codex exec "reply OK"
# ERROR: Missing environment variable: OPENCODEX_API_AUTH_TOKEN
# Expected after native environment integration
codex exec "reply OK"
# request reaches OpenCodex and completes
Alternatives or workarounds
ocx codex-shim install: works, but shares the executable path with Codex and is overwritten by upgrades.
- Exporting the token manually in shell profiles: incomplete for GUI/systemd/non-interactive launches and spreads secret handling across user files.
systemctl --user set-environment: process-session scoped and not durable by itself.
- External daily repair script: effective locally but duplicates lifecycle logic that belongs in OpenCodex.
Additional context
Environment tested:
- OpenCodex 2.33.0
- Codex CLI 0.149.1
- Linux, root-owned server deployment
- OpenCodex proxy at
127.0.0.1:10100
Related shim work: #1441.
Checks
Area
CLI; Authentication and account pool; Service lifecycle; Platform (Linux).
What are you trying to accomplish?
I need Codex CLI processes launched on a Linux server to reach an OpenCodex provider configured with:
without depending on a wrapper installed at the same filesystem path as the Codex binary. The token must remain outside
config.toml, and Codex upgrades must not silently remove the credential injection mechanism.What prevents this today?
env_keytells Codex which process environment variable to read; it does not create that variable. OpenCodex's current solution,ocx codex-shim install, replaces the Codex launcher with a POSIX wrapper that reads the service token and exportsOPENCODEX_API_AUTH_TOKEN.Codex upgrades can replace that path with a symlink or a fresh binary. After that,
codex execfails before reaching the proxy:Validated on OpenCodex 2.33.0 and Codex CLI 0.149.1:
turn.completed; request recorded inusage.jsonlThe current workaround is to reinstall the shim after every Codex update or maintain an external cron that detects and repairs it.
What should OpenCodex do?
Provide and document a shim-independent credential injection mode while preserving the current secure default:
ocx codex-env install, that installs a user-scoped environment generator/drop-in and can be audited/uninstalled; or/root/.opencodex/service-api-tokenwithout storing the secret inconfig.tomlor inheriting it through a shell wrapper.At minimum,
ocx doctorshould detect the invalid combination "provider uses env_key + environment variable absent + shim absent" and print an actionable repair command.The behavior should be idempotent, never print the token, create files with restrictive permissions, and survive Codex upgrades.
Example usage or interface
Before/after behavior:
Alternatives or workarounds
ocx codex-shim install: works, but shares the executable path with Codex and is overwritten by upgrades.systemctl --user set-environment: process-session scoped and not durable by itself.Additional context
Environment tested:
127.0.0.1:10100Related shim work: #1441.
Checks