A Python framework that benchmarks LLMs by having them play the Bulls and Cows code-breaking game through LiteLLM-compatible providers.
openai/openai-cookbook
A collection of Jupyter notebook examples and guides showing how to accomplish common tasks with the OpenAI API.
- Stars
- 76,723
- Forks
- 12,963
- Open issues
- 323
- Last commit
- 4 hours ago
What is it?
The OpenAI Cookbook is a set of example code and written guides for building with the OpenAI API. Most examples are Jupyter notebooks in Python, and the concepts are presented so they can be adapted to other languages.
To run the examples, you need an OpenAI account and API key. The key is read from the OPENAI_API_KEY environment variable, or from a .env file at the repository root when working in an IDE such as Visual Studio Code. The project also links to a page of related resources from around the web, including other tools, guides and courses.
The content is organized as task-oriented recipes rather than a reference manual, so readers can find a worked example for a specific job and adapt it.
Key features
- 01Python Jupyter notebook examples for common OpenAI API tasks
- 02Written guides that explain the concepts behind each recipe
- 03Setup instructions for supplying the API key via environment variable or .env file
- 04A curated list of related tools, guides and courses
Use cases
- Learning how to call the OpenAI API for a specific task
- Copying and adapting a working notebook as a starting point for a project
- Finding guidance on patterns for building applications with OpenAI models
Quick start
- 1
Get an OpenAI API key and set it as the OPENAI_API_KEY environment variable
- 2
Browse the example notebooks at the cookbook site
Things to know
- Running the examples requires an OpenAI account and a paid-capable API key.
Topics
FAQ
- What is openai-cookbook?
- A collection of Jupyter notebook examples and guides showing how to accomplish common tasks with the OpenAI API. The OpenAI Cookbook is a set of example code and written guides for building with the OpenAI API. Most examples are Jupyter notebooks in Python, and the concepts are presented so they can be adapted to other languages.
- Is openai-cookbook free to use? What license does it have?
- openai-cookbook is open source under the MIT license. Check the license terms before using it in commercial products.
- Is openai-cookbook still maintained?
- Actively maintained. The last commit to openai-cookbook was on Oct 21, 2026.
- What can I use openai-cookbook for?
- Learning how to call the OpenAI API for a specific task Copying and adapting a working notebook as a starting point for a project Finding guidance on patterns for building applications with OpenAI models
- How do I install openai-cookbook?
- Get an OpenAI API key and set it as the OPENAI_API_KEY environment variable Browse the example notebooks at the cookbook site
- Where can I get openai-cookbook?
- The source code and installation instructions are on GitHub: https://github.com/openai/openai-cookbook
Summary generated by AI from the project's README. GitHub stats refresh daily.
Related projects
A free, open-source beginner curriculum teaching the Model Context Protocol (MCP) with hands-on examples in C#, Java, JavaScript, Python, Rust and TypeScript.
A Chinese-language step-by-step guide and demo code for learning LLMs, from calling APIs to local deployment and fine-tuning, with Kaggle/Colab versions.
A curated, searchable list of open source GitHub repositories related to ChatGPT, the OpenAI API, and Codex, usable as a Claude Code and Codex skill.
Desktop client for ChatGPT, Claude and other LLMs, running on Windows, macOS and Linux with local data storage.
The official Python library for the OpenAI REST API, with sync and async clients and typed request and response models.