Skip to main content

OpenAI's Codex: A Guide With 3 Practical Examples

Learn what OpenAI's Codex is and how to use it inside ChatGPT to perform coding tasks on a GitHub repository.
May 17, 2025  · 12 min read

OpenAI has just released Codex inside the ChatGPT app. Codex is a tool meant to help developers and teams offload everyday coding work.

In this tutorial, I’ll walk you through how to use Codex inside ChatGPT to perform practical tasks on a GitHub repository, even if you’re not a professional coder. We’ll use Codex to:

  • Apply a code fix and generate a pull request.
  • Explain a complex function inside the codebase.
  • Identify and resolve a bug based on a Q&A-style prompt.

You’ll see how Codex works in a secure sandbox, generates verifiable code changes, and helps you ship faster, without leaving ChatGPT.

What Is OpenAI’s Codex?

OpenAI Codex is a cloud-based software engineering agent that can write and edit code, run tests, fix bugs, and even propose pull requests. Each task is executed in its own sandboxed environment.

Codex is powered by codex-1, a version of the o3 model fine-tuned on real-world development workflows. This agent is built for safety, testability, and developer productivity. You can guide Codex using AGENTS.md files or interact with it directly in ChatGPT’s sidebar.

With Codex CLI, you can bring these capabilities directly into your terminal as well.

Setting Up OpenAI's Codex

Setting up Codex takes just a few minutes. Here’s a simple step-by-step walkthrough to get you started.

Step 1: Locating the Codex tool

Start by logging in to ChatGPT. On the left side toolbar, look for Codex. Note that Codex is currently being rolled out to Pro, Team, and Enterprise users only. 

Codex in ChatGPT

Step 2: Getting started with Codex

Click on Codex, and it will take you to another tab for initial setup. Click on “Get Started” and follow the authentication procedure as shown in the next step.

Codex Get started

Step 3: Multi-factor authentication

Click “Set up MFA to continue” and scan the QR code using your favorite authentication app (like Google Authenticator or Authy). Enter the code to verify and you’re done!

Multi-factor authentication for Codex

Step 4: Connect to GitHub

Once multi-factor authentication is done, we connect Codex to GitHub.

Connect to GitHub for Codex

Step 4.1: Authorize the GitHub connector

“Connect to GitHub” will take you to a pop-up to authorize the GitHub connector. Read through the pop-up and Authorize.

Authorize Connector for Codex

Step 4.2: Adding your GitHub account

Once GitHub is connected, we need to add our account. Under the GitHub organization tab, select “Add a GitHub account.” 

Create environment for OpenAI's Codex

Add your account for OpenAI's Codex

This will take you to another pop-up to “Install and Authorize.” Click to authorize, and all your repositories will appear on the ChatGPT interface. You can also authorize only selected repositories.

Authorize your account for OpenAI's Codex

Step 4.3: Creating an environment

Choose the repository you want to work on and click “Create environment.”

Select Repo for OpenAI's Codex

This will take you to “Data Controls.” Codex is still in active development, and you may see an optional prompt to allow your data to be used for model improvement. You can turn this off and proceed.

Data Controls for OpenAI's Codex

Now your environment is ready to be explored. Codex allows users to start tasks in parallel with pre-picked tasks.

Tasks on OpenAI's Codex

Simply click on “Start tasks” or choose tasks according to your requirements. This will take you to an interface where you can ask questions or ask the agent to code a feature for you.

Start Tasks for OpenAI's Codex

Tasks ready

Once all tasks are ready, select the task you’d like to work on—or you can work on multiple tasks in parallel.

Step 5: AGENTS.md file (optional)

The AGENTS.md file is a special configuration file introduced by OpenAI for use with the Codex platform, specifically designed to help guide AI agents as they work within your codebase. You can think of it as a developer manual for AI teammates, much similar to a README.md, but focused on instructions for autonomous agents. Here is an example AGENTS.md file:

# AGENTS.md

## Code Style
- Use Black for Python formatting.
- Avoid abbreviations in variable names.

## Testing
- Run pytest tests/ before finalizing a PR.
- All commits must pass lint checks via flake8.

## PR Instructions
- Title format: [Fix] Short description
- Include a one-line summary and a "Testing Done" section

When Codex runs a task on your codebase, it:

  • Searches for AGENTS.md files whose scope includes the file(s) it is modifying.
  • Applies the instructions in those files to format, test, and document its changes.
  • Prioritizes deeper nested instructions when multiple files apply (like a cascading config).

OpenAI’s Codex: Three Practical Examples

Let’s explore how Codex can help you in real-world development using three examples I ran on a repository.

Example 1: Basic fixes and typos

Codex sometimes breaks a single request into subtasks—like fixing typos, improving a README, or writing tests, all within the same workspace.

Basic fixes task on OpenAI's Codex

Issues and tasks on OpenAI's Codex

You can start a new task within an existing task based on the initial review, request changes to the existing codebase, or ask questions via the textbox. To extend the task or fix something new, click “Code” and start a new subtask directly.

Suggested changes by OpenAI's Codex

Once satisfied with the changes, click “Push,” which will create a new pull request. After a few seconds, you can click “View Pull Request” to access the pull request and merge it into the main.

Example 2: Codebase explanation

Next, I used Codex for a non-editing task: exploring the codebase and asking what I could do next. This is especially useful if you're new to a project, trying to onboard quickly, or just stuck trying to understand how a certain function works.

CodeBase explanation task by OpenAI's Codex

Codex navigated the project and provided a clean, beginner-friendly breakdown of the codebase’s structure. Instead of just listing files, Codex grouped them by purpose:

  • It highlighted that qwen3_demo.py is the main script, launching two Gradio-based interfaces—one for reasoning mode switching and another for multilingual translation.
  • It identified qwen3_demo.ipynb as an interactive notebook alternative.
  • It pointed out test_qwen3_demo.py for unit testing and README.md for documentation and video walkthroughs.

Beyond that, Codex also listed “Key Points to Know,” like dependencies (Ollama CLI), the role of the _run_ollama function, and tips for extending the interface. It even suggested next steps, such as exploring model versioning, improving the UI, and adding error handling.

Example 3: Find and fix a bug

Codex can scan the entire codebase, identify a bug, propose a fix, and show you a preview of the changes. This process resembles code change reviews on GitHub.

Find bugs and fix them with OpenAI's Codex

You can review the logs to understand the background process for the changes made by clicking “Logs.”

Ask a question in OpenAI's Codex

Codex returns a summary of changes made, along with files created or affected by the changes. You can also ask questions about the changes or ask Codex to write new code to enhance the current implementation.

explaining a function in the codebase using OpenAI's Codex

Updated code files in OpenAI's Codex

Once satisfied with the code fixes, click “Push” and “Create New PR” to open a new pull request.

Create a PR from OpenAI's Codex

After a few seconds, you can click “View Pull Request” to access the pull request and merge it into the main.

Push changes and view pull request

Codex makes it possible to merge the changes with just a few clicks.

lookup PR in GitHub

Merge to main from OpenAI's Codex

The main files are updated seamlessly on the repository.

Updated main from OpenAI's Codex

Why Is Codex Important?

Codex is not just another code-generating tool but a collaborative agent. You can ask it to write, refactor, test, debug, or explain, and it’ll show you the terminal logs, citations, and outputs for each step.

Here are some real-world benefits I’ve observed:

  • Tasks are traceable and verifiable.
  • Codex works in parallel, so you can queue multiple changes.
  • It respects your development setup, especially if you’ve configured conventions through AGENTS.md file.
  • It aligns with human PR standards and can pass CI tests.

To me, this feels like OpenAI just released a software engineering intern.

Conclusion

We learned how Codex can fix bugs, apply feature patches, and explain code logic, all while generating pull requests, running tests, and citing its actions through terminal logs and diffs.

This hands-on walkthrough illustrates how Codex can improve your daily developer workflow, whether you're debugging legacy code, onboarding to a new repo, or triaging maintenance tasks.

As Codex evolves, I anticipate deeper integrations with IDEs, CI pipelines, and task planners, making it a critical companion in the modern software stack. To learn more about Codex, read the official release blog, and you can also find example use cases on OpenAI’s YouTube channel.

To dive deeper into OpenAI’s engineering-focused models and tools, I recommend these blogs:

FAQs

Is Codex different from ChatGPT?

Yes, Codex is a specialized agent for software engineering, optimized for task execution in Git repos.

Do I need to install Codex?

You don't need to install Codex if you use it inside the ChatGPT app. However, for using it inside the terminal, you must install the Codex CLI.

Is OpenAI's Codex safe?

Codex runs in a secure, isolated container. It can’t access the internet or external APIs.


Aashi Dutt's photo
Author
Aashi Dutt
LinkedIn
Twitter

I am a Google Developers Expert in ML(Gen AI), a Kaggle 3x Expert, and a Women Techmakers Ambassador with 3+ years of experience in tech. I co-founded a health-tech startup in 2020 and am pursuing a master's in computer science at Georgia Tech, specializing in machine learning.

Topics

Learn AI with these courses!

Track

Developing AI Applications

21hrs hr
Learn to create AI-powered applications with the latest AI developer tools, including the OpenAI API, Hugging Face, and LangChain.
See DetailsRight Arrow
Start Course
See MoreRight Arrow
Related
Illustration of ChatGPT Canvas

blog

ChatGPT Canvas: A Guide With Examples

Learn how to use OpenAI's ChatGPT Canvas to collaborate with ChatGPT on writing and coding tasks.
François Aubry's photo

François Aubry

8 min

blog

ChatGPT Projects: A Guide With Examples

Learn to create and manage ChatGPT projects with features like custom instructions and file uploads, improving project management and organization in ChatGPT.
François Aubry's photo

François Aubry

6 min

Tutorial

OpenAI Codex CLI Tutorial

Learn to use OpenAI Codex CLI to build a website and deploy a machine learning model with a custom user interface using a single command.
Abid Ali Awan's photo

Abid Ali Awan

9 min

Tutorial

OpenAI's O3: A Guide With Five Practical Examples

Explore five practical examples of how to use OpenAI's o3 model within the ChatGPT application.
Marie Fayard's photo

Marie Fayard

5 min

to do list with a robot -- chatgpt tasks

Tutorial

ChatGPT Tasks: A Guide With 10 Practical Examples

Learn what OpenAI's ChatGPT tasks are, how to use them, and discover 10 practical use cases to automate and schedule your actions.
François Aubry's photo

François Aubry

8 min

code-along

Getting Started with the OpenAI API and ChatGPT

Get an introduction to the OpenAI API and the GPT-3 model.
Richie Cotton's photo

Richie Cotton

See MoreSee More