openai/openai-cookbook

Examples and guides for using the OpenAI API

What is this?

A collection of example code and guides that show you how to do common tasks with the OpenAI API. Think of it as a recipe book — each "recipe" is a working snippet you can copy, run, and adapt.

What will I find inside?

  • Code examples written mostly in Python, but the ideas work in any programming language.
  • Guides that walk you through typical use cases step by step.
  • Everything is also browsable online at cookbook.openai.com.

What do I need to run the examples?

  1. An OpenAI account and an API key (you can create a free account at the signup link in the README).
  2. Set your key as an environment variable named OPENAI_API_KEY.
    • Or, in most IDEs (like Visual Studio Code), create a .env file at the root of your project containing OPENAI_API_KEY=<your API key> — the notebooks will pick it up automatically.

License

MIT License — you can freely use, modify, and distribute the code.

Key facts at a glance

Field Detail
Purpose Example code + guides for the OpenAI API
Primary language Python (concepts are language-agnostic)
Prerequisite OpenAI account + API key
Setup Set OPENAI_API_KEY env var or use a .env file
Website cookbook.openai.com
License MIT

Note: The README does not describe any specific example topics, so this explainer sticks strictly to what the README states.

Related

  • Project
  • Project
  • Project
  • Project