Small CLI helper for using multiple Codex CLI logins on the same machine.
Use it to keep several ChatGPT account logins and API-key logins side by side, then launch Codex with the profile you want:
cx run personal
cx run work
cx run api-openrouterEach profile gets its own isolated CODEX_HOME, so logging in to one account
does not overwrite another account or API-key profile.
From this directory:
./scripts/install.shThis installs:
codex-profileto~/.local/bin/codex-profilecxas a short alias command
Make sure ~/.local/bin is in your PATH.
Create a profile with the guided setup:
cx setupThe setup flow handles profile creation, optional OpenAI-compatible base URL, and account or API-key login. After setup, run Codex with that profile:
cx run <name>For example:
cx run personal
cx run work
cx run api-openrouter
cx run api-deepseekView profile status:
cx statusThe guided setup is the normal path. Use these commands when you want to script or change a specific part of a profile.
Create account profiles manually:
cx init personal
cx login personal
cx init work
cx login workCreate an API-key profile manually:
cx init api-openrouter
export OPENAI_API_KEY='sk-...'
printenv OPENAI_API_KEY | cx login api-openrouter --api-keyprintenv reads an environment variable by name. If you want to paste the key
directly instead, use:
printf '%s\n' 'sk-...' | cx login api-openrouter --api-keySet or unset a profile-specific API base URL:
cx base-url api-openrouter https://api.example.com/v1
cx base-url api-openrouter --unsetDelete a profile:
cx delete old-workSwitch the current shell to a profile:
eval "$(cx switch personal)"
codexThe tool does not automatically copy your current ~/.codex/auth.json into a
profile. Authentication files contain sensitive tokens, so importing an existing
login should be an explicit action.
To turn your current Codex login into the main profile:
cx init main
cp ~/.codex/auth.json ~/.codex-profiles/main/auth.json
chmod 600 ~/.codex-profiles/main/auth.json
cx status mainShort form:
cx setup
cx init <name>
cx login <name> [--api-key]
cx status [<name>]
cx base-url <name> [url|--unset]
cx delete <name>
cx run <name> [codex args...]
cx switch <name>Long form:
codex-profile setup
codex-profile init <name> [--no-copy-config]
codex-profile login <name> [--api-key]
codex-profile status [<name>]
codex-profile list
codex-profile base-url <name> [url|--unset]
codex-profile delete <name>
codex-profile run <name> [codex args...]
codex-profile switch <name>
codex-profile shell-aliases
codex-profile path <name>Profiles are stored in:
~/.codex-profiles/<name>You can override this:
CODEX_PROFILE_ROOT=/path/to/profiles cx statusBy default, new profiles copy non-sensitive config from:
~/.codex/config.tomlOverride the source:
CODEX_PROFILE_SOURCE=/path/to/source cx init workSkip config copying:
cx init clean --no-copy-configPer-profile base URL overrides are tracked in:
~/.codex-profiles/<name>/openai_base_urlWhen this file is present, cx run passes Codex the matching
openai_base_url config override and syncs the same setting into the profile's
config.toml. When it is absent, Codex uses its default endpoint.
When cx setup creates an API-key profile, it asks for only a suffix and names
the profile api-<suffix>. For example, suffix openrouter creates
api-openrouter.
The tool does not read or print auth.json. It lets codex login create and
manage authentication inside the selected profile directory.
Avoid committing profile directories, auth.json, or API keys.