Codex CLI Login: Manage Multiple Accounts
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:
codex logincodex login statusFor multiple work, personal, or client accounts, let each profile own its
Codex state instead of moving auth.json by hand:
aisw initaisw add codex workaisw add codex personalaisw use codex work --state-mode isolatedaisw verifyOpenAI’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:
aisw add codex work --from-liveaisw status --tool codexaisw verifyFor 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:
aisw add codex workaisw add codex personalaisw list codexaisw use codex personal --state-mode isolatedaisw status --tool codexaisw verifycodexStart 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:
aisw context create client-acme --codex acme-codexaisw workspace bind . --context client-acmeaisw workspace guard --mode strictRead 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:
codex login statusaisw status --tool codexaisw verifyIf 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.