I would like to integrate chatgpt into sas, but when I execute the code I get the error shown in the image.
The error message that is shown is> Invalid-COntent Type header. Expexted application/json.
%let chatgpt_api_token = sk-xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx;
%let chatgpt_api_url = "https://api.openai.com/v1/chat/completions";
%let chat_prompt = "Hello, how can I assist you?";
/* Define the SAS macro to interact with the ChatGPT API */
%macro chat_with_gpt(prompt);
/* Prepare the JSON payload for the API request */
filename payload temp;
data null;
file payload;
put '{ "prompt": "' &prompt '", "max_tokens": 50, "model": "gpt-3.5-turbo" }';
run;
/* Submit the API request using PROC HTTP */
filename response temp;
proc http
method="POST"
url=&chatgpt_api_url
in=payload
out=response
headerout=header;
headers "Authorization" = "Bearer &chatgpt_api_token"
"Content-Type" = "application/json";
run;
/* Read the API response and save it to a SAS dataset */
data chatgpt_response;
infile response;
input;
put infile;
/* Parse the JSON response and store it in a variable */
response = infile;
run;
/* Display the API response in the SAS log */
proc print data=chatgpt_response;
run;
%mend;
/* Call the macro to initiate a chat with ChatGPT */
%chat_with_gpt(&chat_prompt);
Tried different solution