-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-opencode.js
More file actions
executable file
·55 lines (44 loc) · 1.31 KB
/
test-opencode.js
File metadata and controls
executable file
·55 lines (44 loc) · 1.31 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
49
50
51
52
53
54
55
#!/usr/bin/env node
const API_KEY = 'sk-85lDP2WBi5wT3hjwe3PUrckciwZwMnBkNSpjgXj4cWdISFj5iOEPQuZ5gZjgzpXA';
const BASE_URL = 'https://opencode.ai/zen/v1/chat/completions';
const models = [
'minimax-m2.5-free',
'glm-5-free',
'kimi-k2.5-free',
'big-pickle'
];
async function testModel(model, useKey) {
const headers = {
'Content-Type': 'application/json'
};
if (useKey) {
headers['Authorization'] = `Bearer ${API_KEY}`;
}
try {
const response = await fetch(BASE_URL, {
method: 'POST',
headers,
body: JSON.stringify({
model,
messages: [{ role: 'user', content: 'Say "Hello from ' + model + '"' }],
max_tokens: 50
})
});
const data = await response.json();
console.log(`\n✓ ${model} ${useKey ? 'WITH' : 'WITHOUT'} key:`);
console.log(` Status: ${response.status}`);
console.log(` Response: ${data.choices?.[0]?.message?.content || JSON.stringify(data)}`);
return true;
} catch (error) {
console.log(`\n✗ ${model} ${useKey ? 'WITH' : 'WITHOUT'} key: ${error.message}`);
return false;
}
}
async function runTests() {
console.log('Testing OpenCode Free Models\n' + '='.repeat(50));
for (const model of models) {
await testModel(model, false);
await testModel(model, true);
}
}
runTests();