This script is a Bash script for calling the OpenAI API to generate text using the GPT-3.5 model. The script takes one argument, which is the user's message to the AI.
To use this script, you first need to obtain an OpenAI API key, which you should replace "INSERT_YOUR_API_KEY" with in the script. You also need to specify the model ID that you want to use, which is set to "gpt-3.5-turbo" in the script.
When you run the script with a message as an argument, it sends a request to the OpenAI API using cURL with the specified API key and model ID. The response is stored in the "response" variable. The script then uses the jq command-line tool to parse the response and extract the generated text, which is stored in the "output" variable. Finally, the script echoes the generated text to the terminal.
If you are using a Mac, you can create a shortcut to automate running this script with a selected text as an argument. Here are the steps to create the shortcut: