Code from this wonderful video tutorial by Code to the Moon
See Rust OpenAI Integration (GPT-3)
The original code from Code to the Moon can be in this git repo
You need an OpenAI account. You can create on here. This is a charged service, but there is a free tier where you can get your first $18.00 worth of the service for free. No credit card required to create an account. You can create an account here. After you create an account you need to get an API Key to authorize your requests to the OpenAI Chat server. When you log in you will see an API KEY link in the left nav-bar. Go there to create an API-KEY. The only time you can see this API-KEY is at creation time so be sure to save it. This tutorial assumes that your API_KEY is stored in an environment variable (so that it is never checked into git). If you select Help in OpenAI and search for "Best Practices for API Key Safety" it will give you detailed instructions on how to create the environment variable on Windows, Mac, and Linux.