OpenAI Cookbook
The OpenAI Cookbook shares sample code for completing common tasks using the [OpenAI API].
To run these examples, you need an OpenAI account and associated API key.
Most of the code examples are written in Python, but the concepts can be applied in any language.
Recently added?
- How to format input for the ChatGPT model [March 1, 2023]
- Embedding search using vector databases and Redis [February 15, 2023]
- Using embeds for website Q&A [February 11, 2023]
- Document Q&A using embeddings [February 11, 2023]
- Visual Embedding in Weights & Biases [February 9, 2023]
- Retrieval-enhanced generative Q&A using Pinecone [February 8, 2023]
Guidelines and Examples
- API usage
- How to deal with rate limiting
- Example parallel processing script to avoid hitting rate limits
- How to use tiktoken to calculate the number of tokens
- How streaming is done
- ChatGPT
- How to format input for the ChatGPT model
- GPT-3
- Guide: How to use large language models
- Guide: Techniques to Improve Reliability
- How to write unit tests using multi-step prompts - text writing example
- Text explanation example
- Text editing example
- Code writing example
- Code explanation example
- Code editing example
- Embed
- Text comparison example
- How to get the embed
- Q&A using embeds
- Semantic search using embeddings
- Use embeds for recommendations
- cluster embedding
- Visualize embedding in 2D or in 3D
- Embed long text
- Fine-tuning GPT-3
- Guide: Best practices for fine-tuning GPT-3 to classify text
- Fine-tuned classification
- DALL-E
- How to use DALL-E to generate and edit images
- Azure OpenAI (alternative API from Microsoft Azure)
- How to get completion from Azure OpenAI
- How to get embeddings from Azure OpenAI
- How to fine-tune GPT-3 using Azure OpenAI
- app
- Document Q&A
- Web crawling Q&A
Related resources
In addition to the code examples here, you can learn about [OpenAI API] from the following resources:
- Try the API in [OpenAI Playground]
- Read about the API in [OpenAI Documentation]
- Discuss the API in the [OpenAI Community Forum]. - Get help in the OpenAI Help Center
- Check out the example tips in OpenAI Examples
- Study Preview with ChatGPT Free Trial
- Stay up to date with the OpenAI Blog
Participate and contribute
If you'd like to see examples or guidance, please feel free to make suggestions on the issues page.