Skip to content

First-class multi-account auth via '--auth-profile' #4432

@bashar94

Description

@bashar94

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_PROFILE env var, so bare codex … 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 ~/.codex exactly 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-profile parsing and defaulting logic.

  • Automatically sets CODEX_HOME/CODEX_ACTIVE_AUTH_PROFILE internally.

  • 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    authIssues related to authentication and accountsenhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions