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 statusResume another profile's conversations with the current profile's login and configuration:
cx run api-openrouter resume-from personalThis opens Codex's interactive resume picker for personal sessions while
running with the api-openrouter profile.
The guided setup is the normal path. Use these commands when you want to script or change a specific part of a profile.
Interactively update an existing profile's base URL or API key login:
cx config api-openrouterCreate 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)"
codexResume sessions from another profile:
cx run work resume-from personal
cx run api-openrouter resume-from work --lastresume-from links the target profile's sessions directory to the source
profile's sessions directory, then runs codex resume --all. Authentication,
base URL, and other config still come from the target profile. If the target
profile already has its own sessions directory, it is moved aside as
sessions.local.<timestamp> before the link is created.
If linking the target to the source would create a sessions symlink loop,
resume-from creates a shared profile named shared-<first>-<second>, moves
the real sessions directory there, and points both profiles at the shared
sessions directory. It stops without changing either profile if the source
sessions link is dangling or cyclic, or if neither side owns a real sessions
directory that can be moved safely.
cx delete <name> refuses to remove a profile while another profile's
sessions link points to it. Repoint the dependent profile first so deletion
cannot leave a dangling sessions link.
The 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 config <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 config <name>
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.