
Understating OpenAI Codex CLI Commands
Image by Author
Introducing OpenAI Codex CLI
We have seen a new era of agentic IDEs like Windsurf and Cursor AI. These code editors not only understand your code but also help you resolve issues, write code, and even build an entire project from scratch. What if I told you there is an even better solution for using AI agents to improve your data science workflow?
Enter OpenAI Codex CLI, a lightweight, open-source command-line tool that brings the power of advanced reasoning models directly to your terminal. Codex CLI allows you to analyze datasets, write and test Python code, and even build machine learning projects.
This tutorial focuses on the features and commands of OpenAI Codex CLI, helping you unlock its potential to build, debug, and enhance any data science project with a single command. If you are interested in installation and setup, you can visit the official GitHub repository for detailed instructions.
Codex CLI Interactive Mode
Once you have successfully installed the Codex CLI, open your terminal, navigate to your project directory, and type codex
to launch the Interactive mode. This will start the Codex CLI with the default model and approval settings.
Note: Make sure your project directory is a Git repository before running Codex. If it isn’t, simply initialize it by typing
git init
.
The interactive mode functions similarly to ChatGPT. You can interact with Codex in a conversational way, asking it to perform tasks and providing follow-up instructions as needed.

Image by Author
Codex CLI Multimodal
The Codex CLI supports multimodal inputs, allowing you to provide images and text for generating responses.
In this example, we will use Codex CLI to analyze a correlation heatmap visualization and generate an analytical report based on it.
Note: The visualization we are using is from the tutorial: Top 6 Python Libraries for Visualization: Which One to Use?.

Image by Author
To analyze the visualization, use the --image
argument and specify the path to the image file.
1 |
codex --image "C:\Users\abida\Desktop\output2.webp" |
The Codex CLI will process the image and provide an initial analysis based on the content of the visualization.

Image by Author
After analyzing the image, you can provide a follow-up instruction to generate a detailed analytical report.
1 |
Please create an analytical report and save it in a markdown format. |
The Codex CLI will then create a markdown file containing the analytical insights derived from the image. This file will be saved locally for you to review or edit later.

Image by Author
Once the markdown file is generated, you can open it in your favorite IDE or text editor to review the analysis.

Image by Author
Codex CLI Approval Modes
The Codex CLI offers three distinct approval modes, giving users varying levels of control over decision-making.
Suggest Mode (Default)
Suggest Mode is the default approval mode in Codex CLI. In this mode, the Codex CLI will ask for your permission at every step, including creating files, editing files, and running shell commands. This mode is ideal for users who want to maintain full control over the process.
1 |
codex --approval-mode suggest "Please analyze the `dataset.csv` file and generate the analytical report in PDF format." |
Codex CLI will first analyze the dataset.

Image by Author
It will then ask for your permission to create a Python file that performs the analysis and generates the report. Simply type “y” to approve.

Image by Author
Next, it will ask for permission to run the Python file in the terminal. Again, type “y” to proceed.

Image by Author
Finally, Codex CLI will provide the summary.

Image by Author
At the end of the process, you will receive the analytical report in PDF format, ready for use.

Image by Author
Auto Edit Mode
In Auto Edit Mode, Codex CLI automatically creates and edits files without asking for your approval. However, it will still prompt you for permission before running any shell commands. This mode is useful for users who want to streamline file creation and editing while retaining control over command execution.
1 |
codex --approval-mode auto-edit "Please analyze the `dataset.csv` file and generate the analytical report in PDF format." |
Codex CLI will automatically create and edit the necessary Python file without asking for your approval, but it will ask permission to run the Python file in the terminal.

Image by Author
The analytical report in PDF format is generated with minimal interaction.

Image by Author
Full Auto Mode
Full Auto Mode is the most autonomous option. In this mode, Codex CLI handles everything, from creating and editing files to running shell commands, without requiring any user input.
1 |
codex --approval-mode full-auto "Please analyze the `dataset.csv` file and generate the analytical report in PDF format." |
Codex CLI will autonomously create the Python file, execute it, and generate the PDF report, all without asking for your approval.

Image by Author
Codex Model Selections
Although the Codex CLI is maintained by OpenAI, it is an open-source project that benefits from regular contributions by the open-source community. This means you can use the Codex CLI not only with OpenAI models but also with third-party proprietary and open-source models.
OpenAI Models
By default, the Codex CLI uses the o4-mini
model. However, you can specify a different OpenAI model by changing the --model
argument.
For example, to use the gpt-4.1
model, you can run the following command:
1 |
codex --model gpt-4.1 --full-auto "Create a Python file for fast loading and cleaning the dataset.csv" |

Image by Author
Using Third Party Providers
The Codex CLI also supports third-party providers, allowing you to use models from other platforms or even run them locally. To switch providers, use the --provider
argument.
Supported providers include:
- openai (default)
- openrouter
- gemini
- ollama
- mistral
- deepseek
- xai
- groq
- Any other provider compatible with the OpenAI API.
To use Groq as the LLM (Large Language Models) provider, you need to set the Groq API key and Base URL as environment variables:
1 2 |
export GROQ_API_KEY="your-api-key-here" export GROQ_BASE_URL="https://your-provider-api-base-url" |
Once the environment variables are set, you can specify Groq as the provider and choose a model, such as deepseek-r1-distill-llama-70b
.
1 |
codex --provider groq --model deepseek-r1-distill-llama-70b "Please create a data analysis script that takes the clean data and runs statistical analysis." |
Within seconds, the Codex CLI will generate a statistical analysis script ready to use.

Image by Author
Codex Quiet Mode
The Codex Quiet mode is a non-interactive mode designed to streamline workflows by displaying the requests sent from the user to the OpenAI server and the server’s responses in JSON format.
1 |
codex --quiet "Explain the analysis_report.py file" |
This mode is particularly useful for debugging, logging, or integrating Codex into larger projects where automation is key.

Image by Author
Codex CLI Reference
Here is the short summary of the features and commands covered in this tutorial.
Option | Alias | Description | Default Value |
---|---|---|---|
--model <model> |
-m | Model to use for completions | o4-mini |
--provider <provider> |
-p | Provider to use for completions | openai |
--image <path> |
-i | Path(s) to image files to include as input | N/A |
--quiet |
-q | Non-interactive mode that only prints the assistant’s final output | N/A |
--approval-mode <mode> |
-a | Override the approval policy: ‘suggest’, ‘auto-edit’, or ‘full-auto’ | suggest |
--auto-edit |
N/A | Automatically approve file edits; still prompt for commands | N/A |
--full-auto |
N/A | Automatically approve edits and commands when executed in the sandbox | N/A |
Final Thoughts
The OpenAI Codex CLI is currently in its experimental phase, which means some features and commands may not work as expected, particularly on Windows systems. However, as the tool progresses toward its beta and stable releases, many of these bugs are expected to be resolved, offering a much smoother and more reliable user experience.
What sets Codex CLI apart from other agent tools on the market is its efficiency, speed, and accuracy. It simplifies complex coding tasks, reduces the number of steps required to solve problems, and generates code that often works right out of the box.
No comments yet.