2023-03-26 19:55:48 +00:00
# OpenAI Cookbook
2022-03-11 02:08:53 +00:00
2023-01-20 22:20:03 +00:00
The OpenAI Cookbook shares example code for accomplishing common tasks with the [OpenAI API].
2022-03-11 02:08:53 +00:00
2023-04-14 19:52:53 +00:00
To run these examples, you'll need an OpenAI account and API key ([create a free account][api signup]).
2022-03-11 02:08:53 +00:00
Most code examples are written in Python, though the concepts can be applied in any language.
2023-03-26 19:54:23 +00:00
[![Open in GitHub Codespaces ](https://github.com/codespaces/badge.svg )](https://github.com/codespaces/new?hide_repo_select=true& ref=main& repo=468576060& machine=basicLinux32gb& location=EastUs)
2023-04-14 19:52:53 +00:00
## Recently added or updated 🆕 ✨
2023-02-14 16:33:59 +00:00
2023-04-14 19:52:53 +00:00
- [Question answering using embeddings ](examples/Question_answering_using_embeddings.ipynb ) [Apr 14th, 2023]
- [Using vector databases for embeddings search ](examples/vector_databases/ ) [various dates]
2023-04-12 08:32:14 +00:00
- [Powering your products with ChatGPT and your own data ](apps/chatbot-kickstarter/powering_your_products_with_chatgpt_and_your_data.ipynb ) [Mar 10th, 2023]
2023-03-01 18:00:07 +00:00
- [How to format inputs to ChatGPT models ](examples/How_to_format_inputs_to_ChatGPT_models.ipynb ) [Mar 1st, 2023]
2023-02-14 18:28:58 +00:00
2023-02-14 16:33:59 +00:00
2023-01-20 22:20:03 +00:00
## Guides & examples
2023-02-12 00:37:34 +00:00
- API usage
- [How to handle rate limits ](examples/How_to_handle_rate_limits.ipynb )
- [Example parallel processing script that avoids hitting rate limits ](examples/api_request_parallel_processor.py )
- [How to count tokens with tiktoken ](examples/How_to_count_tokens_with_tiktoken.ipynb )
- [How to stream completions ](examples/How_to_stream_completions.ipynb )
2023-03-01 18:00:07 +00:00
- ChatGPT
- [How to format inputs to ChatGPT models ](examples/How_to_format_inputs_to_ChatGPT_models.ipynb )
2023-04-12 08:32:14 +00:00
- [Powering your products with ChatGPT and your own data ](apps/chatbot-kickstarter/powering_your_products_with_chatgpt_and_your_data.ipynb )
2023-04-14 19:52:53 +00:00
- GPT
2023-02-12 00:37:34 +00:00
- [Guide: How to work with large language models ](how_to_work_with_large_language_models.md )
- [Guide: Techniques to improve reliability ](techniques_to_improve_reliability.md )
- [How to use a multi-step prompt to write unit tests ](examples/Unit_test_writing_using_a_multi-step_prompt.ipynb )
- Embeddings
- [Text comparison examples ](text_comparison_examples.md )
- [How to get embeddings ](examples/Get_embeddings.ipynb )
- [Question answering using embeddings ](examples/Question_answering_using_embeddings.ipynb )
2023-04-14 19:52:53 +00:00
- [Using vector databases for embeddings search ](examples/vector_databases/Using_vector_databases_for_embeddings_search.ipynb )
2023-02-12 00:37:34 +00:00
- [Semantic search using embeddings ](examples/Semantic_text_search_using_embeddings.ipynb )
- [Recommendations using embeddings ](examples/Recommendation_using_embeddings.ipynb )
- [Clustering embeddings ](examples/Clustering.ipynb )
- [Visualizing embeddings in 2D ](examples/Visualizing_embeddings_in_2D.ipynb ) or [3D ](examples/Visualizing_embeddings_in_3D.ipynb )
- [Embedding long texts ](examples/Embedding_long_inputs.ipynb )
- Fine-tuning GPT-3
- [Guide: best practices for fine-tuning GPT-3 to classify text ](https://docs.google.com/document/d/1rqj7dkuvl7Byd5KQPUJRxc19BJt8wo0yHNwK84KfU3Q/edit )
- [Fine-tuned classification ](examples/Fine-tuned_classification.ipynb )
- DALL-E
- [How to generate and edit images with DALL-E ](examples/dalle/Image_generations_edits_and_variations_with_DALL-E.ipynb )
- Azure OpenAI (alternative API from Microsoft Azure)
2023-03-28 20:25:34 +00:00
- [How to use ChatGPT with Azure OpenAI ](examples/azure/chat.ipynb )
2023-02-12 00:37:34 +00:00
- [How to get completions from Azure OpenAI ](examples/azure/completions.ipynb )
- [How to get embeddings from Azure OpenAI ](examples/azure/embeddings.ipynb )
- [How to fine-tune GPT-3 with Azure OpenAI ](examples/azure/finetuning.ipynb )
- Apps
- [File Q and A ](apps/file-q-and-a/ )
- [Web Crawl Q and A ](apps/web-crawl-q-and-a )
2022-03-11 02:08:53 +00:00
## Related resources
2023-01-20 22:20:03 +00:00
Beyond the code examples here, you can learn about the [OpenAI API] from the following resources:
2022-03-11 02:08:53 +00:00
2023-04-14 19:52:53 +00:00
- Experiment with [ChatGPT]
2023-02-12 00:37:34 +00:00
- 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]
- Stay up to date with the [OpenAI Blog]
2022-03-11 02:08:53 +00:00
2023-01-20 22:20:03 +00:00
## Contributing
2022-08-03 00:43:49 +00:00
2023-01-20 22:20:03 +00:00
If there are examples or guides you'd like to see, feel free to suggest them on the [issues page].
2022-08-03 00:43:49 +00:00
2023-02-12 00:37:34 +00:00
[chatgpt]: https://chat.openai.com/
[openai api]: https://openai.com/api/
[api signup]: https://beta.openai.com/signup
[openai playground]: https://beta.openai.com/playground
[openai documentation]: https://beta.openai.com/docs/introduction
[openai community forum]: https://community.openai.com/top?period=monthly
[openai help center]: https://help.openai.com/en/
[openai examples]: https://beta.openai.com/examples
[openai blog]: https://openai.com/blog/
2023-01-20 22:20:03 +00:00
[issues page]: https://github.com/openai/openai-cookbook/issues