-- Example One -- September 12, 2024
After reading through the introduction and the terminology section of Chapter 1 I finally reached the first coding example, shown below. It's a simple API call to OpenAI's gpt-4o-mini model requesting a translation from English to French. This was not a simple copy paste from the book as the code is already out of date. I could have used the exact same package versions as the book, but I felt it would be helpful for me to go through the process of updating the code. As a precursor to running this example, I needed to sign up for a developer account with OpenAI, create a project API key, and add funds. You read that right — I had to pay to run this tiny example. There may have been a free tier at some point, or maybe OpenAI was originally giving some credits at account creation, but that's no longer the case. Regardless, running this example 5 times for a total of 165 input and 49 output tokens cost less than $0.01. Note that it took about 10 minutes for OpenAI to recognize that I had added funds before I could successfully call the API.
Not very exciting so far, but at least now I've got my coding environment set up and this blog ready to go.