gitmyhub

openai-cookbook

Jupyter Notebook ★ 74k updated 13h ago

Examples and guides for using the OpenAI API

A collection of practical, tested code examples and step-by-step guides for using the OpenAI API, covering common tasks in Python via Jupyter Notebooks.

PythonJupyter NotebookOpenAI APIsetup: easycomplexity 2/5

openai/openai-cookbook is a collection of example code and step-by-step guides for accomplishing common tasks using the OpenAI API — the service that powers tools like ChatGPT and GPT-4. If you are a developer trying to figure out how to do something practical with OpenAI's API, this repository is the reference point for working, tested examples.

To use the examples, you need an OpenAI account and an API key. The setup involves setting an environment variable called OPENAI_API_KEY with your key, or creating a simple configuration file called .env in your project folder that contains it. The examples in the repository are Jupyter Notebooks — an interactive file format that lets you read explanations and run code side by side, making it easier to follow along.

Most of the example code is written in Python, though the README notes the underlying concepts apply to any programming language. The repository is navigable through a dedicated website at cookbook.openai.com. It is released under the MIT license, meaning it is free to use, copy, and adapt.

Where it fits