Python (requests)
Call OneRouter directly with the Python requests library — no SDK required.
Prepare the connection
Create a dedicated OneRouter API key, then choose a complete model ID from the Models page or GET /v1/models. Keep the key in an environment variable or the application's protected credential store.
curl https://onerouter.com/v1/models \
-H "Authorization: Bearer YOUR_API_KEY"Configuration
import requests
r = requests.post(
"https://onerouter.com/v1/chat/completions",
headers={"Authorization": "Bearer YOUR_API_KEY"},
json={
"model": "openai/gpt-5.2",
"messages": [{"role": "user", "content": "Hello"}],
},
)
print(r.json())Verify
Save the configuration, fully restart the app or terminal session, and select the saved OneRouter provider. Send a small test request such as Reply with OK only, then confirm it appears in OneRouter usage logs before enabling tools, file access, or production traffic.
Troubleshooting
| Symptom | How to fix it |
|---|---|
| 401 | Re-enter the complete key and confirm the restarted process can read it. |
| 403 | Confirm the key can access the requested model. |
| 404 | Use https://onerouter.com/v1 as the OpenAI-compatible base URL; do not append a request path unless the client asks for a full endpoint. |
| Model not found | Use the complete ID returned by GET /v1/models, including the provider prefix. |
| Saved settings have no effect | Restart the whole application and check whether workspace-level settings override the user configuration. |