Everybody seems to want to use AI to create Excel formulas, so here is a way of building an interface to the OpenAI ChatGPT 3.5 model. Leila Gharani has already published a video and the Office Script code to call the GPT-3 API. This is for ChatGPT 3.5 which has a different data structure in the JSON.
I did this as an exercise in learning Excel scripting, which is based on Typescript, with some limitations both on the language features and the amount of access it has to the Excel Object Model.
You can download the ChatGPT in Excel demo workbook here. It has two sheets, The API sheet is where you fill in the API key you get when you sign up on openai.com, and it contains the script as plain text. The ChatGPT sheet is where you put in the prompts and then run the script to get the answer.
Enjoy it! Let me know how you get on.