OpenAI Cookbook¶
The OpenAI Cookbook shares example code for accomplishing common tasks with the OpenAI API.
To run these examples, you'll need an OpenAI account and associated API key (create a free account).
Most code examples are written in Python, though the concepts can be applied in any language.
Recently added 🆕 ✨¶
- How to format inputs to ChatGPT models [Mar 1st, 2023]
- Using Vector Databases for Embeddings Search with Redis [Feb 15th, 2023]
- Website Q&A with Embeddings [Feb 11th, 2023]
- File Q&A with Embeddings [Feb 11th, 2023]
- Visualize Embeddings in Weights & Biases [Feb 9th, 2023]
- Retrieval Enhanced Generative Question Answering with Pinecone [Feb 8th, 2023]
Guides & examples¶
- API usage
- How to handle rate limits
- How to count tokens with tiktoken
- How to stream completions
- ChatGPT
- How to format inputs to ChatGPT models
- GPT-3
- Guide: How to work with large language models
- Guide: Techniques to improve reliability
- How to use a multi-step prompt to write unit tests
- Text writing examples
- Text explanation examples
- Text editing examples
- Code writing examples
- Code explanation examples
- Code editing examples
- Embeddings
- Text comparison examples
- How to get embeddings
- Question answering using embeddings
- Semantic search using embeddings
- Recommendations using embeddings
- Clustering embeddings
- Visualizing embeddings in 2D or 3D
- Embedding long texts
- Fine-tuning GPT-3
- Guide: best practices for fine-tuning GPT-3 to classify text
- Fine-tuned classification
- DALL-E
- How to generate and edit images with DALL-E
- Azure OpenAI (alternative API from Microsoft Azure)
- How to get completions from Azure OpenAI
- How to get embeddings from Azure OpenAI
- How to fine-tune GPT-3 with Azure OpenAI
- Apps
- File Q and A
- Web Crawl Q and A
Related resources¶
Beyond the code examples here, you can learn about the OpenAI API from the following resources:
- Try out the API in the OpenAI Playground
- Read about the API in the OpenAI Documentation
- Discuss the API in the OpenAI Community Forum
- Look for help in the OpenAI Help Center
- See example prompts in the OpenAI Examples
- Play with a free research preview of ChatGPT
- Stay up to date with the OpenAI Blog
Contributing¶
If there are examples or guides you'd like to see, feel free to suggest them on the issues page.