Hey all, I have been trying to build a chatgpt macro to take in a basic prompt and return the data within a msgbox - which in itself is pretty basic (heck, chatgpt could probably write the code for me given it would only be like 5 or 6 lines)...
I have a beta-api, however when I try and execute my code, the response header appears to be someone elses question... very unusual.
Has anyone got a working example of VBA code? I have attached mine below (api redacted).
Sub testapi()
Dim http As New MSXML2.XMLHTTP60
Dim json As New Dictionary
Dim prompt As String
prompt = "What is chatgpt or whatever question you want to put here"
json.Add "prompt", prompt
http.Open "POST", "https://api.openai.com/v1/engines/davinci/completions", False
http.setRequestHeader "Authorization", "Bearer "
http.setRequestHeader "Content-Type", "application/json"
http.Send (JsonConverter.ConvertToJson(json))
Dim response As String
response = http.responseText
MsgBox response
End Sub