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 apiEach 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 two account profiles:
cx init personal
cx login personal
cx init work
cx login workCreate an API-key profile:
cx init api
export OPENAI_API_KEY='sk-...'
printenv OPENAI_API_KEY | cx login api --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 --api-keyRun Codex with any profile:
cx run personal
cx run work
cx run apiView profile status:
cx statusDelete 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 init <name>
cx login <name> [--api-key]
cx status [<name>]
cx delete <name>
cx run <name> [codex args...]
cx switch <name>Long form:
codex-profile init <name> [--no-copy-config]
codex-profile login <name> [--api-key]
codex-profile status [<name>]
codex-profile list
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-configThe 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.