-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathai-foundry.js
More file actions
30 lines (26 loc) · 783 Bytes
/
ai-foundry.js
File metadata and controls
30 lines (26 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import ModelClient from "@azure-rest/ai-inference";
import { AzureKeyCredential } from "@azure/core-auth";
import dotenv from 'dotenv';
dotenv.config();
const client = new ModelClient(
process.env.AZURE_INFERENCE_SDK_ENDPOINT,
new AzureKeyCredential(process.env.AZURE_INFERENCE_API_KEY)
);
const messages = [
{ role: "system", content: "You are an helpful assistant" },
{ role: "user", content: "What are 3 things to see in Seattle?" },
];
try {
var response = await client.path("chat/completions").post({
body: {
messages: messages,
max_tokens: 4096,
temperature: 1,
top_p: 1,
model: "gpt-4o",
},
});
console.log(JSON.stringify(response));
} catch (error) {
console.error("Error occurred while making the API call:", error);
}