Is it possible to call an Azure OpenAI API from base SAS and chat with an LLM (i.e. ChatGPT-4)?
Here is an example of what I am thinking. Prompt ChatGPT-4 with "Hello chat gpt" and capture the response in JSON. This just gives me a 404 error.
Has anyone gotten something like this to work?
%let api_key= xxxxxxxxxxxxxxxxxxxxxxxxx;
%let question = %str(%"Hello chat gpt%");
/* Body of the POST request */
filename in temp;
data _null_;
file in;
put;
put "{";
put '"model": "gpt-4", "messages": [{"role": "user", "content": '"&question }]";
put "}";
run;
/* reference that file as IN= parm in PROC HTTP POST */
filename resp "%sysfunc(getoption(WORK))/echo.json";
proc http
method="POST"
url="<End Point URL>/openai/deployments/gpt-4/chat/completions?api-version=2024-02-01"
ct="application/json"
in=in
out=resp;
headers "Authorization" = "Bearer &api_key.";
run;