Skip to main content

Manage multiple OpenAI Codex CLI accounts — switch, check quota, validate tokens

Project description

codex-switch

Manage multiple OpenAI Codex CLI accounts from the command line.

If you use multiple ChatGPT Pro/Plus subscriptions for Codex CLI — for parallel batch evaluation, team usage, or quota management — this tool lets you switch between accounts, check real-time quota, and validate token health without manually copying auth.json files.

Install

# With uv (recommended)
uv tool install codex-switch

# Or with pip
pip install codex-switch

Requires Python 3.11+ and Codex CLI installed.

Quick Start

# Save your current logged-in account
codex-switch save work

# Import another auth.json
codex-switch add ~/Downloads/auth.json personal

# See all accounts at a glance
codex-switch list

# Switch to a different account
codex-switch switch personal

Commands

codex-switch list

Show all saved accounts with plan, quota, token expiry, and live API status:

Saved Codex accounts
   name      email                         plan  quota            access_exp   live
-  --------  ----------------------------  ----  ---------------  -----------  ----
*  pro1      user1@example.com             pro   5h:69% / wk:55%  04-10 10:48  ok
   pro2      user2@example.com             pro   5h:0% / wk:6%    04-13 16:27  ok
   personal  user3@gmail.com               pro   5h:0% / wk:0%    04-13 16:18  ok
  • * = currently active account (matches ~/.codex/auth.json)
  • 5h = 5-hour rolling window usage, wk = 7-day rolling window usage
  • access_exp = when the access token expires (local time)
  • live = real-time API validation result

codex-switch switch <name>

Switch the active Codex CLI account. Backs up current ~/.codex/auth.json automatically:

$ codex-switch switch pro2
Switched to account 'pro2'
Backup: /home/user/.codex-switch/backups/auth-20260403-143022.json
Active auth: /home/user/.codex/auth.json

codex-switch quota [name]

Check real-time quota for the current or a specific account. Does not consume any API quota:

$ codex-switch quota pro1
Quota for pro1
email: user1@example.com
plan:  pro
auth:  chatgpt

bucket           name                 5h                 week               credits  plan
---------------  -------------------  -----------------  -----------------  -------  ----
codex            -                    70% (04-03 19:52)  55% (04-10 00:34)  0        pro
codex_bengalfox  GPT-5.3-Codex-Spark  0% (04-03 23:05)   0% (04-10 18:05)   -        pro

codex-switch validate [name]

Check token health for one account or all saved accounts:

$ codex-switch validate pro2
pro2
  email:   user2@example.com
  plan:    pro
  access:  ok (2026-04-13 08:27)
  id:      expired (2026-04-03 09:27)
  refresh: present
  live:    OK 5h:0% / wk:6%

codex-switch current

Show details about the currently active account:

$ codex-switch current
Current Codex account
name:  pro1
path:  /home/user/.codex/auth.json
email: user1@example.com
plan:  pro
access token: ok (2026-04-10 02:48)
id token:     expired (2026-03-31 03:48)
refresh:      present

codex-switch save <name>

Save the current ~/.codex/auth.json as a named account:

$ codex-switch save work
Saved current auth as 'work'

codex-switch add <path> <name>

Import an auth.json file as a named account:

$ codex-switch add ~/Downloads/auth.json team-account
Imported account 'team-account'

codex-switch remove <name> (alias: rm)

Remove a saved account. Cannot remove the currently active account:

$ codex-switch remove old-account
Removed account 'old-account'

codex-switch rename <old> <new> (alias: mv)

Rename a saved account:

$ codex-switch rename team-account team
Renamed 'team-account'  'team'

How it works

Codex CLI stores authentication in ~/.codex/auth.json. This tool maintains named copies in ~/.codex-switch/ and swaps them when you switch accounts.

Quota checking starts a temporary codex app-server process pointed at the target account, queries the account/rateLimits/read JSON-RPC endpoint, and shuts down. No Codex API quota is consumed.

Storage layout

~/.codex-switch/
├── pro1.json        # saved auth.json for "pro1"
├── pro2.json        # saved auth.json for "pro2"
├── backups/         # automatic backups on switch
│   └── auth-20260403-143022.json
└── .current         # name of the last switched account

Environment variables

For testing or custom setups:

  • CODEX_SWITCH_DATA_DIR — override the account storage directory (default: ~/.codex-switch)
  • CODEX_SWITCH_CODEX_HOME — override the Codex home directory (default: ~/.codex)

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

codex_switch-0.1.0.tar.gz (15.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

codex_switch-0.1.0-py3-none-any.whl (13.2 kB view details)

Uploaded Python 3

File details

Details for the file codex_switch-0.1.0.tar.gz.

File metadata

  • Download URL: codex_switch-0.1.0.tar.gz
  • Upload date:
  • Size: 15.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for codex_switch-0.1.0.tar.gz
Algorithm Hash digest
SHA256 67029ba76d53eeef788ff9b0e8b7fb7cf18ac671b14bc99fc0fdd765946bcd44
MD5 c0ee3fb8d48769f004b2e66da286a62a
BLAKE2b-256 a3900aae7a7f19993409b1d141ef7599a8539e9435676642d2da8c62e625face

See more details on using hashes here.

File details

Details for the file codex_switch-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: codex_switch-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 13.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.10.7 {"installer":{"name":"uv","version":"0.10.7","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"22.04","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for codex_switch-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 844ec25504fe489bf0f963499c7d1884436b74c0ccbea7cb422a4df9df1c1ffb
MD5 9e733faf816ec4659df02fd50926e303
BLAKE2b-256 0684172c4ea29b7192253d0fa015aaf7cec67fdfb069d90c2da8d674d7f9364e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page