-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-api.js
More file actions
48 lines (43 loc) · 1.45 KB
/
Copy pathtest-api.js
File metadata and controls
48 lines (43 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
45
46
47
48
// Test the deepseek/deepseek-r1:free model
const OPENROUTER_API_KEY = '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';
async function testDeepSeekR1() {
console.log('Testing deepseek/deepseek-r1:free model...\n');
try {
const response = await fetch('https://openrouter.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
'Authorization': `Bearer ${OPENROUTER_API_KEY}`,
'Content-Type': 'application/json',
'HTTP-Referer': 'http://localhost:3000',
'X-Title': 'CodeCoach'
},
body: JSON.stringify({
model: 'deepseek/deepseek-r1:free',
messages: [
{
role: 'user',
content: 'Say "Hello World" in Python'
}
],
max_tokens: 100
})
});
console.log(`Response Status: ${response.status}\n`);
if (response.ok) {
const data = await response.json();
console.log('✓ SUCCESS! Model is working!');
console.log('\nResponse:');
console.log(data.choices[0].message.content);
console.log('\n✓ You can now use the application - the API should work!');
} else {
const errorText = await response.text();
console.log('✗ Error Response:');
console.log(errorText);
console.log('\n✗ Model still unavailable on OpenRouter');
}
} catch (error) {
console.log('✗ Request failed:');
console.log(error.message);
}
}
testDeepSeekR1();