-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-litellm.js
More file actions
executable file
·64 lines (59 loc) · 1.9 KB
/
Copy pathtest-litellm.js
File metadata and controls
executable file
·64 lines (59 loc) · 1.9 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
56
57
58
59
60
61
62
63
64
#!/usr/bin/env node
/**
* Test script to verify LiteLLM connection
*
* Usage: node test-litellm.js
*/
const LITELLM_URL = process.env.LITELLM_API_URL || 'http://localhost:4000/v1/chat/completions';
const API_KEY = process.env.LITELLM_API_KEY || 'sk-1234';
const MODEL_NAME = process.env.LITELLM_MODEL || 'Claude Sonnet 4.5';
console.log('🔍 Testing LiteLLM connection...');
console.log('📍 URL:', LITELLM_URL);
console.log('🤖 Model:', MODEL_NAME);
console.log('');
const testPayload = {
model: MODEL_NAME,
messages: [
{ role: 'user', content: 'Say "Hello from LiteLLM!" and nothing else.' }
],
max_tokens: 50
};
fetch(LITELLM_URL, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${API_KEY}`
},
body: JSON.stringify(testPayload)
})
.then(res => {
if (!res.ok) {
return res.text().then(text => {
throw new Error(`HTTP ${res.status}: ${text}`);
});
}
return res.json();
})
.then(data => {
console.log('✅ Success! LiteLLM is working.');
console.log('');
console.log('📨 Response:');
console.log(JSON.stringify(data, null, 2));
console.log('');
console.log('💬 Message:', data.choices[0]?.message?.content || 'No content');
console.log('');
console.log('🎉 You\'re ready to run the Palantir Decomposition Simulator!');
console.log(' Run: npm run dev');
})
.catch(err => {
console.error('❌ Error connecting to LiteLLM:');
console.error('');
console.error(err.message);
console.error('');
console.log('💡 Troubleshooting:');
console.log(' 1. Make sure LiteLLM is running: litellm --model claude-sonnet-4-20250514');
console.log(' 2. Check that it\'s running on http://localhost:4000');
console.log(' 3. Verify your ANTHROPIC_API_KEY is set');
console.log(' 4. See SETUP.md for detailed instructions');
process.exit(1);
});