-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathexample-api-request.js
More file actions
34 lines (30 loc) · 997 Bytes
/
Copy pathexample-api-request.js
File metadata and controls
34 lines (30 loc) · 997 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
31
32
33
34
// // Insert your AIML API Key instead of <YOUR_AIMLAPI_KEY>:
// const API_KEY = '';
// const API_URL = 'https://api.aimlapi.com/v1/chat/completions';
// async function completeChat() {
// const requestBody = {
// model: "bagoodex/bagoodex-search-v1",
// messages: [
// {
// role: "user",
// content: "how to make a slingshot"
// }
// ]
// };
// try {
// const response = await fetch(API_URL, {
// method: "POST",
// headers: {
// "Content-Type": "application/json",
// "Authorization": `Bearer ${API_KEY}`
// },
// body: JSON.stringify(requestBody)
// });
// const data = await response.json();
// console.log(data.choices[0].message.content);
// } catch (error) {
// console.error("Error fetching completion:", error);
// }
// }
// // Run the function
// completeChat();