SkillsMar 29, 2026·1 min read

OpenAI Codex & Cookbook — Official Collection

Official OpenAI resources: Codex CLI coding agent and the OpenAI Cookbook with prompting guides for GPT, Codex, and Realtime API.

TL;DR
Official OpenAI resources: Codex CLI agent for coding plus the Cookbook for GPT prompting guides.
§01

What it is

This collection bundles two official OpenAI resources. The first is Codex, OpenAI's CLI-based coding agent that reads your codebase, proposes changes, and executes them in a sandboxed environment. The second is the OpenAI Cookbook, a repository of practical guides and examples for working with GPT models, the Realtime API, embeddings, and function calling.

These resources target developers who use OpenAI APIs and want reference implementations, prompt engineering patterns, and a coding agent that integrates directly into terminal workflows.

§02

How it saves time or tokens

The Cookbook provides tested prompt templates and code snippets that you can copy directly into your projects. Instead of experimenting with prompt formats from scratch, you start from working examples that OpenAI engineers have validated. This reduces trial-and-error token usage during prompt development.

Codex CLI acts as a coding agent in your terminal. It reads relevant files, generates diffs, and applies changes after your approval. This keeps you in the terminal without switching to a browser-based chat interface.

§03

How to use

  1. Install Codex CLI: npm install -g @openai/codex. Set your OPENAI_API_KEY environment variable.
  2. Run codex in your project directory. Describe what you want to change in natural language. Codex reads your codebase, generates a plan, and shows you the proposed diff.
  3. For the Cookbook, browse the GitHub repository or the docs site. Each guide is a standalone Jupyter notebook or Python script covering a specific use case.
§04

Example

# Using Codex CLI to add error handling
$ codex 'Add retry logic with exponential backoff to the API client in src/api.ts'

# Codex reads src/api.ts, generates a diff:
# + import { retry } from './utils/retry';
# + const response = await retry(() => fetch(url), { maxRetries: 3 });

# You review and approve the changes

Codex operates in a sandbox by default, so it cannot make destructive changes without your explicit approval.

§05

Related on TokRepo

§06

Common pitfalls

  • Codex CLI requires an OpenAI API key with access to the latest models. Costs depend on which model you configure and how much context your codebase requires.
  • Cookbook examples target specific API versions. Some older notebooks may reference deprecated endpoints. Always check the last-updated date on each guide.
  • Codex sandbox mode restricts file system and network access. If you need the agent to run tests or install packages, you must explicitly grant those permissions.

Frequently Asked Questions

Is Codex CLI free to use?+

Codex CLI itself is free and open source. However, it calls OpenAI API endpoints, which are billed per token. Your costs depend on the model you use and the size of context windows required for your codebase.

Can Codex CLI work with Claude or other models?+

Codex CLI is built specifically for OpenAI models. It uses OpenAI's API format and features. For Claude-based coding agents, alternatives like Claude Code or Cline serve a similar role.

What topics does the OpenAI Cookbook cover?+

The Cookbook covers prompt engineering, function calling, embeddings and vector search, fine-tuning, the Realtime API for voice, vision with GPT-4o, structured outputs, and batch processing. Each topic has runnable code examples.

How does Codex CLI differ from GitHub Copilot?+

Codex CLI is a terminal-based agent that reads your full codebase and makes multi-file changes. GitHub Copilot is an IDE-integrated autocomplete tool that suggests code inline. Codex operates at the project level while Copilot works at the line level.

Can I contribute to the OpenAI Cookbook?+

Yes. The Cookbook is open source on GitHub and accepts community contributions. OpenAI provides contribution guidelines for adding new examples or updating existing ones.

Citations (3)
🙏

Source & Thanks

Created by OpenAI. Licensed under Apache 2.0 / MIT.

Discussion

Sign in to join the discussion.
No comments yet. Be the first to share your thoughts.

Related Assets