First-class multi-account auth via '--auth-profile'
Open 💬 17 comments Opened Sep 29, 2025 by bashar94
💡 Likely answer: A maintainer (etraut-openai, contributor)
responded on this thread — see the highlighted reply below.
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_
17 Comments
PR #4457
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.
Definitely need this as I have a personal account and corporate account. At this point, I might just maintain two installations of codex.
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
surprised OpenAI seems uninterested in this.. odd.
@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.
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/
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.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/codexmuxI 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.
@venkatd, we offer the ability to purchase additional credits if you need more usage on top of your subscription.
I have a work account, and a personal account.
@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.
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 cratesNice 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
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.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.