Checking the Codex login status shows whether the current CLI environment already has cached credentials before an interactive session, automation run, or remote-shell task starts.
The codex login status subcommand prints the active authentication mode for the local CLI profile. Current OpenAI Codex docs state that the CLI supports both ChatGPT and API key sign-in, and the CLI and IDE extension reuse the same cached login details.
Current OpenAI authentication docs also say file-based credentials are stored in auth.json under CODEX_HOME, which defaults to /~/.codex, while other setups use the operating system credential store. The status check does not change that state, but it is a decisive preflight for scripts because the command exits with 0 only when credentials are present.
Related: How to log in to Codex with device authentication
Related: How to log in to Codex with an API key
Related: How to log out of Codex
Steps to check Codex login status:
- Run the status command in the same shell or terminal environment that will run Codex.
$ codex login status Logged in using ChatGPT
Current local verification returned Logged in using ChatGPT for an authenticated local profile, and current OpenAI CLI docs describe the command as printing the active authentication mode.
- Match the returned line to the current credential state.
Logged in using ChatGPT means the local profile is using a cached ChatGPT session. API key profiles report API key authentication instead, while Not logged in means the current environment has no cached credentials.
- Print the shell exit status immediately after the command when a script needs a machine-readable result.
$ codex login status Logged in using ChatGPT $ echo $? 0
Current OpenAI CLI docs say codex login status exits with 0 when credentials are present, which current local verification also confirmed. The same check in a clean HOME with no cached login returned Not logged in and exit 1.
- Start the appropriate sign-in flow if the status check reports no cached login.
$ codex login
Plain codex login starts the default ChatGPT browser flow. Use How to log in to Codex with device authentication for headless terminals and How to log in to Codex with an API key for automation or other programmatic environments where API key authentication is the better fit.
- Run the status command again after signing in and confirm that the expected authentication mode is now active.
$ codex login status Logged in using ChatGPT
This is the decisive post-login success check before starting an interactive session or a scripted run.
Mohd Shakir Zakaria is a cloud architect with deep roots in software development and open-source advocacy. Certified in AWS, Red Hat, VMware, ITIL, and Linux, he specializes in designing and managing robust cloud and on-premises infrastructures.
