← All projects
Learning resources

OpenAI Cookbook

Example code and guides from OpenAI showing how to do common tasks with its AI models.

What it does

The OpenAI Cookbook is a collection of worked examples for using the OpenAI API, the doorway that lets programs talk to OpenAI's models such as the ones behind ChatGPT.

Most examples are written in Python, but the ideas apply to any programming language. The examples can also be browsed on the cookbook's own website.

To run them, you need an OpenAI account and an API key, which is a kind of password for programs.

Who it's for

Developers who are building with OpenAI's models and want tested starting points.

Can I use it without coding?

Developers only. The guides are free to read, but using them means writing or running code with an OpenAI API key. New to this? Start here.

Can I run it?

Cost
Free, but needs an AI accountThe software is free, but it uses an online AI service (like OpenAI or Anthropic), which usually charges for use.
Privacy
Sends what you give it to an online service
API key
Needed. An API key is a password-like code from an online AI service. What's that?

Try it

  1. Browse the examples and guides on the Cookbook website.
  2. To run the examples yourself, create an OpenAI account and get an API key.

Using Claude Code, Cursor or another AI coding assistant? Paste the prompt and it will walk you through the setup.New to this?

Before you install

  • Only download from the official GitHub page. Copies with similar names exist for many popular projects.
  • License (MIT): Very permissive: free to use, change and share, including for business.
  • Keep your API key private. Never paste it into websites or share it, and set a spending limit with the AI service.
  • What you type or upload is sent to an online service. Avoid sharing private or sensitive information.
  • More on staying safe

Where people are talking about it