Authentication
API Authentication
Using an API key
fetch('https://llm.onerouter.pro/v1/chat/completions', {
method: 'POST',
headers: {
Authorization: 'Bearer <API_KEY>',
'Content-Type': 'application/json'
},
body: JSON.stringify({
model: 'gpt-4o',
messages: [
{
role: 'user',
content: 'What is the meaning of life?',
},
],
}),
});import OpenAI from 'openai';
const openai = new OpenAI({
baseURL: 'https://llm.onerouter.pro/v1',
apiKey: '<API_KEY>'
});
async function main() {
const completion = await openai.chat.completions.create({
model: 'gpt-4o',
messages: [{ role: 'user', content: 'Say this is a test' }],
});
console.log(completion.choices[0].message);
}
main();If your key has been exposed
Last updated