OpenAI Codex CLI is a lightweight coding agent that runs locally, providing multimodal inputs, rich approvals workflow, and terminal-based AI-assisted development
Codex CLI supports multiple authentication methods including ChatGPT account login and OpenAI API key authentication.
codex login [OPTIONS] [SUBCOMMAND]--api-key <API_KEY> # Login with OpenAI API keylogin status # Show current login statuscodex logout [OPTIONS]# Interactive ChatGPT login (opens browser)
codex loginThis method:
# Login with OpenAI API key
codex login --api-key sk-your-api-key-hereThis method:
# Check current authentication status
codex login statusThe status command shows:
# Standard ChatGPT login
codex login
# Check if currently logged in
codex login status
# Login with API key
codex login --api-key sk-1234567890abcdef...
# Logout from current session
codex logoutcodex logincodex login --api-key <your-key>~/.codex/# If browser doesn't open automatically
codex login
# Then manually navigate to the URL shown in terminalFor servers or CI environments without browsers:
codex login on a machine with browser access# If authentication expires, simply login again
codex login
# Check status if unsure
codex login statusIf migrating from API key to ChatGPT account:
# Logout from API key
codex logout
# Login with ChatGPT
codex loginAuthentication settings can be overridden with configuration:
# Use different auth with config profile
codex --config-profile team login
# Override auth-related config
codex -c auth_method=api_key exec "test command"OPENAI_API_KEY: Can be used instead of login for API key authenticationCODEX_HOME: Override location of authentication storageInstall with Tessl CLI
npx tessl i tessl/npm-openai--codex