BookmarkSubscribeRSS Feed
supp
Pyrite | Level 9

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;

SAS Innovate 2025: Call for Content

Are you ready for the spotlight? We're accepting content ideas for SAS Innovate 2025 to be held May 6-9 in Orlando, FL. The call is open until September 25. Read more here about why you should contribute and what is in it for you!

Submit your idea!

How to choose a machine learning algorithm

Use this tutorial as a handy guide to weigh the pros and cons of these commonly used machine learning algorithms.

Find more tutorials on the SAS Users YouTube channel.

Discussion stats
  • 0 replies
  • 486 views
  • 0 likes
  • 1 in conversation