-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-api-manager-direct.js
More file actions
38 lines (32 loc) · 1.21 KB
/
Copy pathtest-api-manager-direct.js
File metadata and controls
38 lines (32 loc) · 1.21 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
// Test api-key-manager directly to see logs
require('dotenv').config({ path: '.env.local' });
const { fetchWithKeyRotation, getApiKeyManager } = require('./lib/api-key-manager.ts');
async function testDirect() {
console.log('--- Testing ApiKeyManager Direct ---\n');
try {
const manager = getApiKeyManager();
console.log('Initial Status:', manager.getStatus());
console.log('\nMaking request...');
const response = await fetchWithKeyRotation('https://openrouter.ai/api/v1/chat/completions', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
model: 'mistralai/mistral-7b-instruct:free',
messages: [{ role: 'user', content: 'test' }],
max_tokens: 5
})
});
console.log('\nResponse Status:', response.status);
if (response.ok) {
console.log('✅ Success!');
} else {
console.log('❌ Request failed with status:', response.status);
}
} catch (error) {
console.log('\n❌ EXCEPTION CAUGHT:');
console.log(error.message);
}
}
testDirect();