Codex CLI Login: Manage Multiple Accounts

Codex CLI · Tested with aisw v0.3.10 and Desktop v0.2.1 · Updated October 8, 2026

Run `codex login` for the native ChatGPT flow, or use the documented API-key input path. For more than one account, authenticate each profile inside its own `CODEX_HOME` with `aisw add codex <profile>`, then switch with `aisw use codex <profile>` and verify before starting Codex.

The short answer

For a normal Codex CLI sign-in, run the provider’s native command:

Terminal window
codex login
codex login status

For multiple work, personal, or client accounts, let each profile own its Codex state instead of moving auth.json by hand:

Terminal window
aisw init
aisw add codex work
aisw add codex personal
aisw use codex work --state-mode isolated
aisw verify

OpenAI’s Codex CLI supports native ChatGPT authentication and API-key-based usage. AI Switcher manages the local profile boundary; it does not bypass OpenAI authentication, account limits, or provider terms.

Sign in with the native Codex flow

Run codex login and complete the browser or device authentication flow. For API-key or access-token use, follow the current Codex CLI authentication interface rather than placing secrets directly in shell history. The official Codex authentication documentation is the source of truth for provider flags and supported login methods.

If the account is already active and you only need a one-time local profile, capture the live state:

Terminal window
aisw add codex work --from-live
aisw status --tool codex
aisw verify

For ChatGPT-managed accounts, treat a live import as bootstrap. The durable multi-account workflow authenticates directly inside each isolated profile so future token refreshes remain tied to that profile’s CODEX_HOME.

Save and switch multiple accounts

Create a profile for each account and authenticate it through the native Codex flow launched by aisw:

Terminal window
aisw add codex work
aisw add codex personal
aisw list codex
aisw use codex personal --state-mode isolated
aisw status --tool codex
aisw verify
codex

Start Codex after the switch. An existing process can retain its previous environment, so changing the selected profile is not a hot swap for a running session.

Keep Codex accounts tied to repositories

If one repository must always use the client profile, bind the directory to a context and start with warning mode before enforcing it:

Terminal window
aisw context create client-acme --codex acme-codex
aisw workspace bind . --context client-acme
aisw workspace guard --mode strict

Read the Codex CLI switching guide for the shortest workflow, or manage multiple Codex CLI accounts for isolated state and auth.json details.

If login or account status looks wrong

Run these checks from the terminal that will launch Codex:

Terminal window
codex login status
aisw status --tool codex
aisw verify

If Codex still shows the old account, close the agent, select the intended profile, verify it, and start a new process. Do not copy auth.json between profiles when ChatGPT-managed refresh state is involved; isolated CODEX_HOME is the safer boundary.

Frequently asked questions

Do I need codex logout to change Codex CLI accounts?

Not with saved profiles. codex logout followed by codex login works for one account at a time. With aisw, each profile keeps its own CODEX_HOME, so aisw use codex <profile> changes accounts without signing out.

How do I log in to Codex CLI?

Run `codex login` and complete the native ChatGPT flow, or use the current documented API-key or access-token input path. For a reusable named profile, run the login through `aisw add codex <profile>`.

Can I use multiple Codex CLI accounts?

Yes. Give each account its own aisw profile and isolated `CODEX_HOME`, then switch profiles before starting a new Codex process.

Why did Codex login work but the wrong account remain active?

A running Codex process can retain its previous environment. Check `aisw status`, run `aisw verify`, and launch a new process after selecting the intended profile.

Make your next account switch a single command.

Install aisw, run aisw init, and the accounts you are signed into become named profiles.

brew install burakdede/tap/aisw