OpenAI has recently launched Codex CLI (Command-Line Interface), a powerful tool that brings the intelligence of OpenAI's latest reasoning models directly to your computer's terminal. While its name might suggest it's only for coders, this tool is valuable for anyone who wants to analyze local documents, data, or content without uploading them to the cloud.
This guide provides a detailed, step-by-step walkthrough of installing Codex CLI on Windows 11. We'll break down each step in simple terms, ensuring that even those new to the command line can get up and running quickly.
OpenAI Codex CLI is a lightweight, open-source AI-powered coding agent that runs right in your terminal.
It is revolutionizing how we interact with AI. This powerful, yet lightweight, tool brings the intelligence of advanced language models directly to your command line, allowing you to read, edit, and run code locally with unparalleled ease. But Codex CLI isn't just for developers! If you've ever wished you could harness the power of online LLM models with your own local data, documents, or repositories without the security concerns of uploading them to the cloud, Codex CLI is for you.
Think of it as having a super-smart AI assistant that can understand your instructions, analyze your files, and even execute commands, all within the secure confines of your own computer. Whether you're a seasoned coder, a curious "vibe coder," or simply someone who wants to leverage AI with sensitive information, Codex CLI opens up a world of possibilities.
It’s more than a tool for software developers. It’s a local AI assistant that can analyze files, automate tasks, run commands, and help you create or understand code — without ever sending your private documents or data to the cloud.
If you've been asking:
“Can I use ChatGPT with my own files — but locally and privately?”
“Is there a way to build with AI without exposing my data?”
“Can I use AI tools without needing an IDE or writing scripts?”
Then Codex CLI is for you.
Codex CLI integrates seamlessly into their existing workflow, offering intelligent assistance without disrupting their flow and working directly within local repositories, allowing them to take advantage of AI to:
Write better code.
Build features faster.
Debug problems with intelligent error analysis and squash bugs more efficiently.
Generate code snippets and complete functions.
Refactor existing code for better performance.
Understand unfamiliar code with ease.
Analyze code and entire repositories.
Prototype ideas directly from the terminal.
Learn and explore via interactive Q&A with the AI LLM.
Codex CLI provides a secure and powerful way to leverage AI for a wide range of applications:
Read and analyze local confidential documents without cloud exposure.
Interact with local data.
Help understand complex information.
Generate content based on private local information sources and files.
Summarize large reports or datasets
Create structured data from unstructured information.
Convert information between different formats.
Create or modify files on your computer.
Automate tasks without the risk of exposing information to the cloud.
All while keeping data completely private.
For it may be its most important benefit: Your data never leaves your computer unless you specifically choose to share it. This makes Codex CLI perfect for working with sensitive information that you wouldn't want to upload to cloud-based AI services.
With just your terminal, an API key, and a few setup steps, you’ll be ready to talk to your code, folders, or local documents like you talk to ChatGPT.
CLI (Command-Line Interface) tools are programs you interact with by typing commands in a text-based interface. Unlike graphical applications where you click buttons, CLI tools work by typing commands into a text-based interface called a terminal or console. They offer a direct and efficient way to control your computer, and while they might seem intimidating at first, they're incredibly versatile once you get the hang of them.
Codex CLI can be installed and configured on Windows 11 in simple 9 steps. To make the instructions easier to follow, I have divided them into 3 parts:
1. Configuring your OpenAI Platform account to run Codex CLI.
2. Configuring PowerShell on your computer to run CLI tools.
3. Installing the necessary software in your computer (Node.js, npm and Codex CLI).
Each step is clear, practical, and designed for beginners. Let's begin.
Sign Up or Log In to your OpenAI Platform Account
If you don’t have an account with OpenAI (ChatGPT), you need to create one.
If you have a ChatGPT account, you can use that account.
🔗 Go to https://platform.openai.com and Sign Up or Log In.
You need to complete a quick digital onboarding with a valid ID (national id, driver’s license or passport) and a camera (from your computer or mobile device) in order to confirm your identity and verify your account.
🔗 Go to https://platform.openai.com/settings/organization/general and follow the instructions under Verifications.
Codex CLI connects to OpenAI models via its API, which has a cost. A small one, but still a cost. And it requires setting up a payment method and a minimum charge of $5 USD.
🔗 Add your payment method at https://platform.openai.com/settings/organization/billing/payment-methods
Projects are like workspaces for your coding tasks in OpenAI’s platform.
Make sure you have at least one project created and active in your OpenAI account.
🔗View your projects or add one at: https://platform.openai.com/settings/organization/projects
An API Key is like the secret key that lets Codex CLI talk to OpenAI's brain. A key is required to run Codex. Each key is linked to an existing Project.
Create your API key at
🔗 https://platform.openai.com/settings/organization/api-keys
🔗 https://platform.openai.com/api-keys
ℹ️ Copy and store it securely. OpenAI will not display it again completely. The key should not be published or shared with any one. Keep it safe!
Running scripts via CLI tools like codex and npm requires changing your computer’s policy to allow script execution.
Learn more about what this means here: https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_execution_policies
Once you're comfortable, you can proceed by changing the permission to allow running scripts from Windows PowerShell.
Open Windows PowerShell by pressing the Windows key, type "PowerShell", and click on "Windows PowerShell". A PowerShell terminal window pops up!
🖥️ In the PowerShell terminal window that opens, type the following and press Enter:
Set-ExecutionPolicy RemoteSigned -Scope CurrentUser
ℹ️ If prompted for confirmation, type Y or A (for Yes to All) and press Enter.
ℹ️ If you ever want to revert the permission to disallow script execution, just open Windows PowerShell and type: Set-ExecutionPolicy Restricted -Scope CurrentUser
In order to connect to OpenAI models, Codex requires your OpenAI API Key.
You can set it for the current session from within PowerShell.
🖥️ In the PowerShell terminal window, type and press Enter:
$env:OPENAI_API_KEY="your_openai_api_key"
ℹ️ "Your_openai_api_key" is the API Key you created before and safely stored.
If you lost it, it’s ok. Go back to Step 5 and generate another Key.
✅ Step 7a: Verify the variable has been set.
🖥️ Just type the following in the PowerShell terminal and press enter.
echo $env:OPENAI_API_KEY
It should display the key.
ℹ️ Note: This is temporary for the current session only.
To set the API key permanently and persistent across sessions every time you open PowerShell:
🖥️ Check your PowerShell profile path by typing and pressing enter in the Windows Powershell:
echo $PROFILE
🖥️ Open this file to edit it with notepad by typing and pressing enter :
notepad $PROFILE
🖥️ Or of if you prefer VScode, type:
code $PROFILE
If the file doesn't exist, it will ask to create it - say yes!
🖥️ Then, copy the instruction we used before for the environment variable and paste it in the file and save it:
$env:OPENAI_API_KEY="your_openai_api_key"
ℹ️ "Your_openai_api_key" is the API Key you created before and safely stored.
Codex CLI needs Node.js to run. It's like the engine under the hood!
On Windows, the easiest way to install Node.js is to download and run a prebuilt Node.js Windows Installer from: 🔗 https://nodejs.org/en/download
Run the downloaded file and follow the on-screen instructions. The installer will take care of setting up Node.js and its helpful buddy, npm (which stands for Node Package Manager – it helps manage coding tools!).
🖥️ After installation, verify it is properly installed by typing the following in Windows PowerShell and pressing Enter:
node -v
npm -v
Both should return version numbers.
ℹ️ If you closed PowerShell, just do the following to open a new window:
Press the Windows key, type "PowerShell", and click on "Windows PowerShell". A PowerShell terminal window pops up!
🖥️ In PowerShell, install Codex CLI globally:
npm install -g @openai/codex
ℹ️ If you closed PowerShell, just do the following to open a new window:
Press the Windows key, type "PowerShell", and click on "Windows PowerShell". A PowerShell terminal window pops up!
That’s it, you should be all set!
🖥️ To start Codex CLI, simply type in PowerShell:
codex
And start prompting. Your prompts will apply to the folder where you started codex from.
So, it is better to start codex from a specific directory. In Windows PowerShell, create a folder to work on or go to the directory or repository where you want the prompts to apply (files to analyze) or the output to be created and then run codex using the command mkdir (make directory) and/or cd (change directory).
🖥️ If you want to run a complex process and not be prompted for confirmation, use the --approval-mode full-auto parameter, as in:
mkdir recruitment_app
cd recruitment_app
codex --approval-mode full-auto "create a modern recruitment app to register and evaluate job candidates"
Not much. The following command consumed 114,000 tokens with a cost of US$0.17 cents. It created a responsive website with its css style sheet:
codex --approval-mode full-auto write a responsive website for an insurance agent
Now, remember, one of the key advantages of OpenAI Codex CLI is that your code remains local and is not uploaded to the OpenAI cloud. This is worth its price, in particular for those working on proprietary software, documents and repositories.
OpenAI's Codex CLI is a powerful tool that represents a significant step forward in bringing AI assistance to your local environment.
Whether you're a developer seeking to boost your productivity, a professional who wants to analyze private documents without exposing them to the cloud, or someone looking for a secure way to leverage AI with your local data, Codex CLI offers a compelling solution.
By following this comprehensive guide, you can unlock the potential of AI in your terminal and explore a new era of coding and data interaction by combining the power of OpenAI's most advanced models with the privacy and security of local processing. The possibilities are limited only by your imagination.
#OpenAI #CodexCLI #DevTools #VibeCoding #AI #Windows11 #CommandLine #DataSecurity #LLM
While tools like LM Studio or Ollama also let you run LLMs locally for free, Codex CLI connects you directly to OpenAI’s most powerful hosted models — but on your terms, in your terminal, with total control over what gets shared.
Use them together. Experiment freely. Build boldly.
Let me know how it goes and share your experiences!
✍️ Carlos Miranda Levy | thesocialentrepreneur.com