Hi, I have been playing around trying to get a response from the ChatGPT API directly in AppGameKit Studio using SendHTTPRequest, but I can't seem to figure it out. I asked ChatGPT for help and it said this:
To use the AGK Studio SendHTTPRequestASync function to get a response from the ChatGPT API, you can follow these steps:
Set up your API credentials: Obtain an API key from OpenAI by signing up for the ChatGPT API. Make sure you have the API key handy, as you will need it in the HTTP request headers.
Construct the HTTP request: Use the SendHTTPRequestASync function to send an HTTP request to the ChatGPT API endpoint. Pass the appropriate parameters:
iHTTP: The ID of the connection to use. You can create an HTTP connection using the CreateHTTPConnection function in AGK Studio.
szServerFile: The file to request from the server, which includes the endpoint and any necessary query parameters.
For the ChatGPT API, this would be the endpoint URL provided by OpenAI, such as https://api.openai.com/v1/chat/completions.
szPostData: The raw post data to send to the server. In the case of the ChatGPT API, this would be the JSON payload containing the input data for generating the response.
You can use AGK Studio's built-in functions or a third-party plugin to create the JSON payload with the appropriate input data, such as the text prompt for ChatGPT.
Handle the asynchronous response: The SendHTTPRequestASync function returns immediately and the server's reply is received in the background.
You can periodically check the status of the response using the GetHTTPResponseReady function, which returns a boolean value indicating whether the response is ready.
Retrieve and parse the response: Once the response is ready, you can use the GetHTTPResponse function to retrieve the response data,
which would be the generated text or other information from the ChatGPT API.
You can then parse the response data, for example using AGK Studio's built-in JSON functions or a third-party plugin,
to extract the relevant information you need.
Use the response in AGK Studio: You can then use the extracted information from the ChatGPT API response in AGK Studio as needed,
such as displaying it in a text box, processing it further, or integrating it into your game or application logic.
Please note that the exact implementation details may vary depending on your specific use case and the requirements of the ChatGPT API.
Make sure to refer to the documentation of AGK Studio and the ChatGPT API for specific instructions and guidelines.
I'm not sure if that is correct advice or a ChatGPT hallucination.

But if anybody could give me an example of AppGameKit tier 1 code that works to access the ChatGPT API, I would be really grateful.