Guide
How to switch accounts in Codex.
There are two ways to change the account Codex uses: sign out and in again each time, or keep every account signed in in its own folder and pick the folder.
The built-in way: log out, log in
codex logout
codex login # opens the browser for ChatGPT sign-in
codex login status # which kind of login is active
Simple, but you can only have one account at a time, and every switch goes through the browser again. Sessions and history of both accounts end up in the same ~/.codex.
API key instead of ChatGPT
Codex can also sign in with an OpenAI API key instead of a ChatGPT plan. codex login --help lists the options for your version; recent versions read the key from standard input:
printenv OPENAI_API_KEY | codex login --with-api-key
Switch without signing out: one folder per account
Codex keeps its login in the folder named by CODEX_HOME (default ~/.codex). Sign each account in once, in its own folder, and switching becomes choosing a folder:
mkdir -p ~/.codex-work ~/.codex-client
CODEX_HOME=~/.codex-work codex login
CODEX_HOME=~/.codex-client codex login
CODEX_HOME=~/.codex-work codex # work
CODEX_HOME=~/.codex-client codex # client
codex # your main account
Nothing is ever signed out, and two accounts can run at the same time. The multiple accounts guide covers aliases and sharing your setup between them.
Or let a tool do it
- codex-switch, free and open source:
codex-switch create work,codex-switch work. - Switch for Codex, the Mac app: every account one click away in the app, the menu bar or a floating bar, in the Codex app and the terminal, with the signed-in email and plan on each profile.
A side-by-side comparison has the other options too.
Questions
How do I log out of Codex?
Run codex logout. It removes the login from the current CODEX_HOME (~/.codex by default).
How do I see which account Codex uses?
codex login status says how you're signed in. The email and plan of a ChatGPT login are in the id_token inside auth.json in your CODEX_HOME; Switch for Codex and codex-switch list show them per profile.
Can I switch accounts without logging out?
Yes, with one CODEX_HOME folder per account. Sign each folder in once, then run Codex with CODEX_HOME pointing at the one you want.
Switch for Codex does this with one click on a Mac: every account in its own Codex app window and in your terminal, all open at once, from the app or the menu bar. $9.99 once, no subscription.