-
-
Notifications
You must be signed in to change notification settings - Fork 3
Getting Started
This page takes you from nothing to a working multi-account setup: install codex-switch, add accounts, and pick the best one before a Codex session.
- OpenAI Codex CLI installed, plus at least one ChatGPT account that can log in to Codex.
- Codex must use its file credential store, because codex-switch works by atomically replacing
$CODEX_HOME/auth.json. If needed, add this to$CODEX_HOME/config.toml(normally~/.codex/config.toml):
cli_auth_credentials_store = "file"Explicit keyring, auto, and ephemeral stores are rejected — permanently by design, because OS keyrings cannot provide the locking and atomic-replace guarantees switching depends on (see why only the file store is supported). A managed Codex configuration with forced_login_method = "api" is also incompatible, because codex-switch manages ChatGPT login profiles. In both cases codex-switch stops with an actionable error instead of modifying authentication state; after switching to the file store, log in again.
macOS / Linux:
curl -fsSL https://github.com/xjoker/codex-switch/releases/latest/download/install.sh | bashThis installs to the user-owned $HOME/.local/bin and configures PATH for zsh, bash, and fish; other shells receive a manual PATH instruction. An older direct install under /usr/local/bin is migrated once: the new user binary is installed first, then the installer removes the old copy with one elevated operation when required. Administrators can explicitly keep a system-wide install with --system; system installs may require sudo for later updates.
If the installer says
Installing to /usr/local/bin (requires sudo)without an explicit--system, stop it: that is the retired script from the repository's oldmasterbranch. Use the Release URL above.
Windows PowerShell:
irm https://github.com/xjoker/codex-switch/releases/latest/download/install.ps1 | iexWindows installs under %LOCALAPPDATA%\Programs\codex-switch and updates the user PATH.
Homebrew (macOS / Linux):
brew install xjoker/tap/codex-switchHomebrew distributes stable releases only and keeps ownership of its binary; update it with brew upgrade xjoker/tap/codex-switch, not with self-update.
Note: this project is not distributed on crates.io. Do not
cargo install codex-switch— that package name belongs to an unrelated project of the same name.
Verify the installation:
codex-switch --versioncodex-switch login worklogin opens a browser PKCE flow; the alias (work) is optional and can be renamed later. On a headless machine, use the device-code flow instead:
codex-switch login --device serverIf you already have auth.json backups, import a file or scan a whole directory. Imports are parsed, identity-checked, validated against the usage service, and saved under collision-free aliases. An import never overwrites an existing profile: a Team workspace ID proves access to that workspace, not ownership of another user's saved credentials.
codex-switch import ~/auth-backupscodex-switch also notices logins performed outside of it: when the live auth.json contains an account it does not track (for example after a plain codex login), an interactive run offers to save it as a profile.
codex-switch list # accounts, quota, availability
codex-switch tui # interactive dashboard
codex-switch use # switch to the best eligible account
codex-switch launch # select, start Codex, restore auth afterwardsuse without an alias ranks all accounts with the adaptive scoring algorithm; use <alias> switches explicitly. Codex reads authentication at startup, so restart Codex after a manual switch — or use launch, which handles staging and restoration for you.
Saved profiles, cache, configuration, and daemon state default to ~/.codex-switch (%USERPROFILE%\.codex-switch on Windows). The live Codex file stays at $CODEX_HOME/auth.json. See Configuration for every path and setting.
Never share profile files, auth.json, tokens, proxy credentials, or unredacted --debug output.
- Learn account, quota, launch, and daemon workflows in the Feature guide.
- Look up exact commands and TUI shortcuts in the Command reference.
- Keep the binary current with Updating.