Repository navigation
Description
What feature would you like to see?
Today Codex CLI assumes a single account, with state stored under ~/.codex/. Users who need to juggle multiple ChatGPT/API accounts (for example, those with multiple accounts, multiple API keys, or who work for different clients) must manually swap CODEX_HOME, copy auth files, or repeatedly log in and out. This is tedious, time-consuming, and not user-friendly.
I would like to see first-class multi-account support:
-
A global
--auth-profile <name>flag that routes all config, auth, and session state into~/.codex/profiles/<name>/. -
A default profile can be set via
CODEX_PROFILEenv var, so barecodex …still works as expected. -
Profile names are normalized/validated (safe slugs, no
.., etc). -
Interactive hints (
login,exec,resume) include the active profile name so it’s clear which account you’re in. -
Backwards compatibility: if no flag/env is set, Codex continues to use
~/.codexexactly as before.
This matches common CLI conventions (like aws --profile) and makes it trivial to keep personal/work accounts isolated without shell hacks.
Are you interested in implementing this feature?
Yes. I have already implemented a working version in a fork:
-
Added
--auth-profileparsing and defaulting logic. -
Automatically sets
CODEX_HOME/CODEX_ACTIVE_AUTH_PROFILEinternally. -
Updated login/logout, exec, and resume flows to respect the active profile.
-
Added tests to confirm per-profile isolation of
auth.json,config.toml, and sessions. -
Updated interactive exit hints to show the profile.
-
Updated getting-started docs to explain both the legacy single-account flow and the new multi-profile workflow.
Happy to open a PR once the team acknowledges this direction.
Additional information
No response
Activity
bashar94 commentedon Sep 29, 2025
PR #4457
RW21 commentedon Oct 28, 2025
There is an issue of unintended messing up of MCP auths between profiles, but overall I think this feature is needed. Especially in the case of working between multiple openAI organization keys.
rirze commentedon Oct 29, 2025
Definitely need this as I have a personal account and corporate account. At this point, I might just maintain two installations of codex.
bashar94 commentedon Oct 30, 2025
Since they are not merging this feature and we all need it, I have a bash script for you to do the same thing. It is not as smooth as Codex's built-in functionality but you can log in and switch accounts easily using this: https://github.com/bashar94/codex-cli-account-switcher
[-]feat(cli): first-class multi-account auth via '--auth-profile'[/-][+]First-class multi-account auth via '--auth-profile'[/+]cdrum commentedon Mar 6, 2026
surprised OpenAI seems uninterested in this.. odd.
etraut-openai commentedon Mar 6, 2026
@cdrum, we generally prioritize feature requests based on upvotes. It's not that we're uninterested. Just focused on features that are more highly requested.
burakdede commentedon Mar 26, 2026
Native
--auth-profileis the right long-term answer.For anyone who needs this today without patching the binary:
aiswtakes a similar approach externally. Manages isolatedCODEX_HOMEdirectories per profile:Each profile gets its own
auth.jsonandconfig.toml. Forcescli_auth_credentials_store = "file"so credentials are portable rather than stuck in OS keyring.The cross-tool part is the main differentiator from Codex-specific solutions: same commands also work for Claude Code (via
CLAUDE_CONFIG_DIR) and Gemini CLI. One tool instead of separate per-tool hacks.Docs: https://burakdede.github.io/aisw/
prashantchoudhary commentedon Mar 30, 2026
A jenv/pyenv/ssh-config like support will be the best. Where we can configure
folder level accountsthat can be used for all the subfodlers. And Codex automatically switches account based on this rule, just like jenv switches Java versions.slatkisasa commentedon Apr 6, 2026
Sharing in case this helps someone else:
I ended up putting together a small Go CLI to manage multiple Codex accounts more easily (codexmux). Mostly vibe-coded, but it’s lightweight and fast:
https://github.com/slatkisasa/codexmux
You can also install it via Homebrew:
brew install slatkisasa/tap/codexmuxvenkatd commentedon May 8, 2026
I assume most people here have multiple accounts as a workaround to the codex limits. They run out so they have to buy a 2nd account.
If there was a way to pay $200 more to get double limits, etc, that would solve the problem at the root cause.
etraut-openai commentedon May 8, 2026
@venkatd, we offer the ability to purchase additional credits if you need more usage on top of your subscription.
cdrum commentedon May 8, 2026
I have a work account, and a personal account.
deksden commentedon May 27, 2026
@etraut-openai
Do simple trick: allow profile customisation of auth file in profiles v2, so people can have different auth files via profile if needed.
If they need separate sessions between personal/work accounts, they can use different codex homes. Cli already fully support it, but you need to support CODEX_HOME in codex.app!
This all can be done via simlinks tricks and cli utils / wrappers / automation, but official support can make things simplier.
Ducksss commentedon Jun 3, 2026
Sharing a candidate implementation I put together for this request:
Branch: https://github.com/Ducksss/codex/tree/PinZheng/auth-profiles-review
Compare: https://github.com/openai/codex/compare/main...Ducksss:PinZheng/auth-profiles-review?expand=1
It adds first-class auth profiles via
--auth-profile NAMEandCODEX_PROFILE=NAME, resolving each profile to an isolated Codex home under$CODEX_HOME/profiles/NAME. The branch wires the selected profile through CLI/TUI/app-server/daemon/MCP/plugin/marketplace/cloud-task flows, scopes MCP OAuth state by profile, preserves existing default-profile MCP keyring credentials, and documents the difference between config profiles and auth profiles.I could not open an upstream PR from this account because GitHub rejected PR creation against
openai/codex, but the branch is pushed and ready for maintainers to inspect or pull.Validation run:
cargo fmt --allgit diff --checkcargo test -p codex-utils-home-dircargo test -p codex-rmcp-client oauth::testscargo test -p codex-cli --bin codex auth_profilecargo test -p codex-core build_exec_request_preserves_windows_workspace_rootscargo checkacross home-dir, cli, core, rmcp, mcp, app-server, daemon, chatgpt, cloud-tasks, tui, and exec cratesdrogers0 commentedon Jun 3, 2026
Nice to see @Ducksss's candidate
--auth-profilebranch — native profiles are the right fix here. For anyone who needs something in the meantime (and across providers), I builtaistat: it switches both Claude and Codex from one binary, plus live usage reporting. The existing external switchers like aisw cover storage and manual switching cleanly; aistat's different axis is the reporting, which is what I needed for headroom-based routing. Codex switching rewrites the live~/.codex/auth.jsonin place:It also reports usage per account (the input to headroom-based auto-pick):
Without
--to, auto-pick goes by 5h headroom — the rate-limit-aware behavior proposed in #9648 / PR #9651, just applied at the switch boundary instead of per-request. It reports Copilot too, though there's no switch there since GitHub's auth model differs.https://github.com/drogers0/aistat
Ducksss commentedon Jun 11, 2026
Quick follow-up: I refreshed the candidate branch against current
main(273a4aa) and force-pushed the updated commit: https://github.com/Ducksss/codex/tree/PinZheng/auth-profiles-reviewValidation on the refreshed branch:
cargo test -p codex-utils-home-dir;cargo test -p codex-rmcp-client oauth::tests;cargo test -p codex-cli --bin codex auth_profile;cargo test -p codex-core build_exec_request_preserves_windows_workspace_roots; and a multi-packagecargo checkacross the touched crates. Since fork PRs are restricted to collaborators, I can split this into smaller reviewable branches if maintainers prefer.burakdede commentedon Jun 15, 2026
I've been following account/profile management requests not only in Codex, but also in Claude Code and Gemini CLI.
At this point, I think this is becoming a coding-agent-agnostic workflow problem rather than a tool-specific feature request.
A lot of developers now juggle:
The current workaround across most tools is some combination of logout/login cycles, environment variables, credential file swapping, shell aliases, or separate terminals.
Because I kept running into this across multiple coding agents, I've been maintaining
AI Switcher(aisw):https://github.com/burakdede/aisw
Not suggesting it as a replacement for first-party support here. If anything, it has convinced me that the demand is real because exactly the same requests keep appearing across Codex, Claude Code, and Gemini CLI issue trackers.
One thing I've learned while building it is that users usually need more than just account switching:
Recently I added
contexts, which are essentially bundles of profiles that can be switched together:That experience made me think the long-term solution might be broader than just
auth switchand closer to first-class identity/context management.Would love to see native support land because I think this is becoming a common workflow for power users regardless of which coding agent they use.
jyongchul commentedon Aug 17, 2026
Adding a concrete multi-host quota-rotation use case.
Environment:
We rotate between two subscription accounts when a weekly quota is exhausted. The current workaround is not just an authentication switch: changing CODEX_HOME or logging out/in also changes the effective config, session namespace, skill/plugin discovery, and local runtime state. In practice, this creates configuration drift between hosts and makes it hard to tell whether a failure is caused by the selected account or by a different runtime/config generation.
A first-class profile feature would be much safer if it separated these dimensions:
Desired UX:
codex auth profile list/status/switchwithout copyingauth.json;authProfile,configGeneration, and whether a new lifecycle is required;The operational impact is repeated authentication/config diagnosis and duplicated turns. The user reports roughly twice the usual token/time consumption during affected rotations; I do not have a clean token baseline, so that number should be treated as user-reported impact rather than measured telemetry.
No auth.json, token, account email, or private config is attached.
patrickallensimpson commentedon Sep 2, 2026
I put together a server-side proposal for the variant where accounts share the same local sessions and memories instead of using separate
CODEX_HOMEdirectories: patrickallensimpson#1The implementation keeps one home for threads, rollouts, config, skills, and memories, but namespaces credentials per account session in the existing auth backend. The shared
account-sessions.jsoncontains metadata only—no access or refresh tokens. It implements the merged v2 add/list/switch/logout protocol, blocks account changes during active turns, and includes a two-account end-to-end isolation test.GitHub denied this account permission to create a PR directly against
openai/codex, so the fork PR is the reviewable branch of record. It is based on currentmainand also cross-references the existing lifecycle draft in #25383.larcane97 commentedon Sep 29, 2026
Had the same drift problem. What I do now is give each account its own CODEX_HOME but symlink config.toml, AGENTS.md, skills/ and plugins back to the main ~/.codex, so it's mainly auth.json and the state/log dbs that are actually per account. Config and skills stay the same whichever account is active. Sessions can go either way, keep sessions/ and history.jsonl per home, or symlink them too if you want one shared resume list.
Put this into a small tool if it helps anyone: https://github.com/larcane97/clausona (mine, it also handles claude code). It's a stopgap though, +1 for native --auth-profile.
jakoes-wu commentedon Oct 2, 2026
Until something like
--auth-profilelands, a workaround that works today is to give every account its ownCODEX_HOME. I wrapped that in a small tool, multi-codex (https://github.com/jakoes-wu/multi-codex):multi-codex add workcreates~/.cx/workand acodex-worklauncher,multi-codex login worklogs in, andcodex-work/codex-personalthen run side by side in different terminals. It can also give each account its own proxy, pick the account per project directory (multi-codex bind workonce, thencodex-auto), and turn an existing~/.codexinto an account without logging in again. It's a third-party wrapper aroundCODEX_HOME, so it doesn't change how Codex itself handles auth.