mirror of
https://github.com/diegosouzapw/OmniRoute.git
synced 2026-08-12 02:02:13 +03:00
docs: add quickstart code examples for Python, Node.js, PHP and cURL (#9922)
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.
This commit is contained in:
28
examples/quickstart/python_requests.py
Normal file
28
examples/quickstart/python_requests.py
Normal file
@@ -0,0 +1,28 @@
|
||||
"""
|
||||
OmniRoute Quickstart — Python (requests library)
|
||||
================================================
|
||||
Run: pip install requests (if not already installed)
|
||||
python python_requests.py
|
||||
"""
|
||||
|
||||
import requests
|
||||
|
||||
# Your local OmniRoute server — started with: npx omniroute
|
||||
API_URL = "http://localhost:20128/v1/chat/completions"
|
||||
|
||||
headers = {
|
||||
"Content-Type": "application/json",
|
||||
"Authorization": "Bearer dummy-key", # Any string works for free/keyless providers
|
||||
}
|
||||
|
||||
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?"}
|
||||
],
|
||||
}
|
||||
|
||||
response = requests.post(API_URL, headers=headers, json=data)
|
||||
response.raise_for_status()
|
||||
print(response.json()["choices"][0]["message"]["content"])
|
||||
Reference in New Issue
Block a user