mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-11 01:32:22 +03:00
Add examples/quickstart/ with minimal copy-paste scripts that let new users get a response from a local OmniRoute server in under a minute, without needing to read the full docs first. Files added: - examples/quickstart/python_requests.py (requests library) - examples/quickstart/nodejs_axios.js (axios) - examples/quickstart/curl_terminal.sh (bash one-liner) - examples/quickstart/php_curl.php (cURL extension) - examples/quickstart/README.md (table + key-settings cheatsheet) README.md: add one sub-line pointer to examples/quickstart/ below the existing zero-config curl snippet, matching the surrounding <sub> style.
32 lines
893 B
JavaScript
32 lines
893 B
JavaScript
/**
|
|
* OmniRoute Quickstart — Node.js (axios)
|
|
* =======================================
|
|
* Run: npm install axios
|
|
* node nodejs_axios.js
|
|
*/
|
|
|
|
const axios = require('axios');
|
|
|
|
// Your local OmniRoute server — started with: npx omniroute
|
|
const API_URL = 'http://localhost:20128/v1/chat/completions';
|
|
|
|
const headers = {
|
|
'Content-Type': 'application/json',
|
|
'Authorization': 'Bearer dummy-key', // Any string works for free/keyless providers
|
|
};
|
|
|
|
const data = {
|
|
model: 'felo/auto', // Keyless, works out of the box — no sign-up needed
|
|
stream: false,
|
|
messages: [
|
|
{ role: 'user', content: 'Hello! What can you do?' },
|
|
],
|
|
};
|
|
|
|
axios.post(API_URL, data, { headers })
|
|
.then(res => console.log(res.data.choices[0].message.content))
|
|
.catch(err => {
|
|
console.error('Error:', err.message);
|
|
if (err.response) console.error('Server replied:', err.response.data);
|
|
});
|