Above you can see a lesson from our Use Codex CLI to Enhance Your Python Projects video course by Rodrigo Girão Serrão.
Important: Open your terminal and start Codex before following along with the video above:
$ codex
Type codex and press Enter to start a new Codex session. Ideally, you start Codex in a project folder that you trust rather than in your user home folder.
Watch the video above and follow along as Rodrigo sets up Codex for the first time. You can ignore the instructions mentioning rpcontacts towards the end.
The most important step for you is to authenticate Codex by logging in. On the first run, Codex will prompt you to sign in. You have two options:
- Sign in with ChatGPT (recommended): choose Sign in with ChatGPT in the prompt and complete the sign-in in your browser. If you’re not inside Codex, you can also run
codex loginin your terminal. This works with ChatGPT Plus or higher (Plus, Pro, Business, Edu, or Enterprise). - Use an OpenAI API key: Codex reads the key from standard input, so pipe it in. For example, if your key is stored in the
OPENAI_API_KEYenvironment variable, runprintenv OPENAI_API_KEY | codex login --with-api-keyon macOS and Linux, or$env:OPENAI_API_KEY | codex login --with-api-keyin Windows PowerShell.