Loongphy/codex-auth
Loongphy/codex-auth has 2,854 GitHub stars and 163 forks. GitHot measured -1 stars in 24 hours. Last checked 2026-11-07 19:39 UTC. Last push 2026-11-02.
A CLI tool to switch and manage Codex accounts
Measured star growth
- in 24h
- -1
- in 7 days
- Collecting history
- in 15 days
- Collecting history
- in 1 month
- Collecting history
Net star changes over overlapping periods, not daily totals. Missing measurements are left blank. Stars measure attention, not software quality.
README.md
OriginalCodex Auth

codex-auth is a command-line tool for switching Codex accounts.
Install
Install with npm:
npm install -g @loongphy/codex-auth
Installed command:
codex-auth
You can also run it without a global install:
npx @loongphy/codex-auth list
Supported Platforms
codex-auth works with these Codex clients:
- Codex CLI
- VS Code extension
- Codex App
[!IMPORTANT] For Codex CLI and Codex App users, switch accounts, then restart the client for the new account to take effect.
If you want seamless automatic account switching without restarting, use the forked
codext, an enhanced Codex CLI.Install it with
npm i -g @loongphy/codextand runcodext.Codex App users can use
codex-auth app, but it is not stable. See Details.
Install the Codex CLI even if you mainly use the VS Code extension or the App, because it makes adding accounts easier:
npm install -g @openai/codex
After that, you can use codex-auth login, or codex-auth login --device-auth to sign in and add accounts more easily.
Commands
Detailed command documentation lives in docs/commands/README.md.
Account Management
| Command | Description |
|---|---|
codex-auth list [--live] [--active] [--api|--skip-api] |
List stored accounts and usage state |
codex-auth login [--device-auth] |
Run codex login, then add the current account |
codex-auth switch [--live] [--api|--skip-api] |
Switch the active account interactively |
codex-auth switch <query> |
Switch directly by row number or account selector |
codex-auth remove [--live] [--api|--skip-api] |
Remove accounts interactively |
codex-auth remove <query> [<query>...] |
Remove accounts by selector |
codex-auth remove --all |
Remove all stored accounts |
codex-auth reset <query> |
Use the soonest-expiring reset credit for one account |
codex-auth alias set <query> <alias> |
Set an alias for an account |
codex-auth alias clear <query> |
Clear the alias for an account |
Import and Maintenance
| Command | Description |
|---|---|
codex-auth import <path> [--alias <alias>] |
Import a single auth file or batch import a folder |
codex-auth import --cpa [<path>] |
Import CLIProxyAPI token JSON |
codex-auth import --purge [<path>] |
Rebuild registry.json from auth files |
codex-auth export [<dir>] |
Export stored account auth files |
codex-auth export --cpa [<dir>] |
Export CLIProxyAPI token JSON |
codex-auth clean |
Delete managed backup and stale account files |
Configuration
| Command | Description |
|---|---|
codex-auth config live --interval <seconds> |
Configure live TUI refresh interval |
codex-auth completion <bash|zsh|fish|pwsh> |
Print a shell completion script |
Shell Completion
Install Fish completions with:
mkdir -p ~/.config/fish/completions
codex-auth completion fish > ~/.config/fish/completions/codex-auth.fish
source ~/.config/fish/completions/codex-auth.fish
Install Bash completions with:
mkdir -p ~/.local/share/bash-completion/completions
codex-auth completion bash > ~/.local/share/bash-completion/completions/codex-auth
Install Zsh completions with (the directory must be in fpath before compinit runs):
mkdir -p ~/.zsh/completions
codex-auth completion zsh > ~/.zsh/completions/_codex-auth
echo 'fpath=(~/.zsh/completions $fpath)' >> ~/.zshrc
autoload -Uz compinit && compinit
Install PowerShell completions with:
codex-auth completion pwsh >> $PROFILE
Tab cycles candidates inline by default on PowerShell 5.1 and 7+; for a menu picker, add Set-PSReadLineKeyHandler -Key Tab -Function MenuComplete to your profile.
Quick Examples
codex-auth list
codex-auth list --active
codex-auth switch
codex-auth switch 02
codex-auth remove work
codex-auth import /path/to/auth.json --alias personal
codex-auth list --skip-api
Codex App
[!IMPORTANT] The
appcommand is experimental and may never become a stable feature.It is designed to enable seamless account switching without restarting the Codex App. By leveraging the
CODEX_CLI_PATHenvironment variable, it dynamically injects our managed codext CLI to handle authentication on the fly.The
appcommand is constrained by ongoing changes in the official Codex App and Codex CLI. It may not always take effect and may also break your app.
| Command | Description |
|---|---|
codex-auth app [--id <id>] [--codex-cli-path <path>] |
Experimental: launch Codex App with detected defaults, CODEX_HOME, CODEX_CLI_PATH, and platform overrides |
Support seamless account switching including:
- New Chat
- Restoring or resuming an existing conversation
- Continuing a previously completed, interrupted, or manually stopped conversation
Uninstall
Remove the npm package:
npm uninstall -g @loongphy/codex-auth
Q&A
Why is my usage limit not refreshing?
API-backed refresh is the default. When you pass --skip-api, codex-auth reads the newest ~/.codex/sessions/**/rollout-*.jsonl file instead. Recent Codex builds often write token_count events with rate_limits: null. The local files may still contain older usable usage limit data, but in practice they can lag by several hours, so local-only refresh may show a usage limit snapshot from hours ago instead of your latest state.
- Upstream Codex issue: openai/codex#14880
Run the API-backed default with:
codex-auth list
Run one local-only command with:
codex-auth list --skip-api
Verify with:
codex exec "say hello"
Build a GUI with JSON
If you are building a GUI on top of the current codex-auth client, use the supported --json command variants to receive machine-readable results. See the JSON API documentation for supported commands and the compatibility contract.
Disclaimer
This project is provided as-is and use is at your own risk.
Usage Data Refresh Source:
codex-auth supports two sources for refreshing account usage/usage limit information:
- API (default): The tool makes direct HTTPS requests to OpenAI's endpoints using your account's access token. This enables both usage refresh and team name refresh.
curlmust be available at runtime. - Local-only: With per-command
--skip-api, the tool scans local~/.codex/sessions/*/rollout-*.jsonlfiles for usage data and skips team name refresh API calls. This mode is safer, but it can be less accurate because recent Codex rollout files often containrate_limits: null, so the latest local usage limit data may lag by several hours.
API Call Declaration:
By using the default API-backed refresh, this tool will send your ChatGPT access token to OpenAI's servers for usage limit, reset-credit, and team name refresh. Redeeming a reset credit with codex-auth reset (or from the list --live rail) additionally sends a consume request — the only state-mutating call this tool makes — and it is never sent during a refresh. See docs/api.md for the exact endpoints.
This behavior may be detected by OpenAI and could violate their terms of service, potentially leading to account suspension or other risks. The decision to use this feature and any resulting consequences are entirely yours.
Explore related projects
codecrafters-io/build-your-own-x
Master programming by recreating your favorite technologies from scratch.
560,847 starspublic-apis/public-apis
A collective list of free APIs
497,093 starsmorluto/rea
Reverse engineer anything with agents, from app behavior down to native binaries.
441,612 starsopenclaw/openclaw
The AI that really does things. Any OS. Any Platform. The lobster way. 🦞
394,159 stars