Skip to main content

Documentation Index

Fetch the complete documentation index at: https://mintlify.com/openai/openai-cookbook/llms.txt

Use this file to discover all available pages before exploring further.

The OpenAI Cookbook is a community-driven collection of practical examples, Jupyter notebooks, and guides for working with the OpenAI API. Whether you’re building your first chatbot, designing a multi-agent system, or fine-tuning a model for a specialized domain, you’ll find real working code here.

Quickstart

Make your first OpenAI API call and understand the core concepts in minutes.

Agents & Automation

Build intelligent agents using the OpenAI Agents SDK with tools, handoffs, and guardrails.

Embeddings & Search

Use text embeddings for semantic search, classification, clustering, and recommendations.

Fine-tuning & Evals

Customize models with your own data using SFT, DPO, or Reinforcement Fine-Tuning.

Explore by topic

Models & Prompting

Understand how LLMs work and write better prompts for GPT-5, o-series, and more.

Function Calling

Give models access to external tools and APIs through structured function calls.

Responses API

Use the Responses API for stateful, tool-augmented completions with built-in search.

Vision & Multimodal

Analyze images, documents, and video frames with GPT-4o and GPT-5.4.

Audio & Speech

Transcribe audio with Whisper and generate natural speech with the TTS API.

Image Generation

Create and edit images using DALL-E 3 and GPT Image generation models.

Getting started

1

Get your API key

Sign up for an OpenAI account at platform.openai.com and create an API key in the dashboard.
2

Set your environment variable

Export your API key so the examples can authenticate automatically.
export OPENAI_API_KEY="sk-..."
3

Install the Python SDK

Install the official OpenAI Python library to follow along with any cookbook notebook.
pip install openai
4

Run your first call

Make a simple chat completion to verify everything is working.
from openai import OpenAI

client = OpenAI()

response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Say hello!"}]
)
print(response.choices[0].message.content)
Most cookbook examples are written in Python. The concepts apply to any language — the OpenAI API has official SDKs for Python, Node.js, and more, plus a REST API you can call from any HTTP client.

Build docs developers (and LLMs) love