-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest-proxy.cjs
More file actions
33 lines (31 loc) · 916 Bytes
/
Copy pathtest-proxy.cjs
File metadata and controls
33 lines (31 loc) · 916 Bytes
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
const fs = require('fs');
const env = fs.readFileSync('.env.local', 'utf8');
const keyMatch = env.match(/VITE_OPENROUTER_KEY=(.*)/);
const key = keyMatch ? keyMatch[1].trim().replace(/['"]/g, '') : '';
const handler = require('./api/chat.js').default;
const req = {
method: 'POST',
headers: {
'x-openrouter-cache': 'true',
'x-openrouter-cache-ttl': '600'
},
body: {
model: 'meta-llama/llama-3.3-70b-instruct:free',
messages: [{ role: 'user', content: 'hello test' }],
plugins: [{ id: 'response-healing' }],
response_format: { type: 'json_object' },
max_tokens: 1500
}
};
const res = {
setHeader: () => {},
status: (code) => {
console.log('STATUS:', code);
return {
json: (data) => console.log('JSON:', JSON.stringify(data, null, 2)),
end: () => console.log('END')
};
}
};
process.env.OPENROUTER_KEY = key;
handler(req, res).catch(console.error);