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-2026-white.png



April 27 – 30 | Gaylord Texan | Grapevine, Texas

Registration is open

Walk in ready to learn. Walk out ready to deliver. This is the data and AI conference you can't afford to miss.
Register now and lock in 2025 pricing—just $495!

Register now

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