-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-api.js
More file actions
44 lines (37 loc) · 1.45 KB
/
Copy pathtest-api.js
File metadata and controls
44 lines (37 loc) · 1.45 KB
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
35
36
37
38
39
40
41
42
43
44
require('dotenv').config();
async function testFireworksAPI() {
console.log('Testing Fireworks AI API...');
console.log('API Key:', process.env.FIREWORKS_API_KEY ? 'Found' : 'Missing');
try {
const response = await fetch('https://api.fireworks.ai/inference/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': `Bearer ${process.env.FIREWORKS_API_KEY}`,
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'accounts/fireworks/models/llama-v3p3-70b-instruct',
messages: [
{
role: 'user',
content: 'Say hello in one sentence.'
}
],
max_tokens: 50
})
});
console.log('Response Status:', response.status);
console.log('Response Headers:', Object.fromEntries(response.headers.entries()));
const data = await response.json();
console.log('Response Data:', JSON.stringify(data, null, 2));
if (response.ok) {
console.log('✅ API test successful!');
console.log('AI Response:', data.choices[0].message.content);
} else {
console.log('❌ API test failed');
}
} catch (error) {
console.error('❌ Test error:', error.message);
}
}
testFireworksAPI();