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;

hackathon24-white-horiz.png

The 2025 SAS Hackathon Kicks Off on June 11!

Watch the live Hackathon Kickoff to get all the essential information about the SAS Hackathon—including how to join, how to participate, and expert tips for success.

YouTube LinkedIn

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
  • 1300 views
  • 0 likes
  • 1 in conversation