HyperRouter Python SDK
Official Python SDK for HyperRouter — AI model aggregation platform.
Installation
pip install hyperrouter
Quick Start
from hyperrouter import HyperRouter
client = HyperRouter(api_key="mr-xxx")
response = client.chat.completions.create(
model="openai/gpt-4o",
messages=[{"role": "user", "content": "Hello!"}],
)
print(response.choices[0].message.content)
Async Usage
from hyperrouter import AsyncHyperRouter
client = AsyncHyperRouter(api_key="mr-xxx")
response = await client.chat.completions.create(
model="anthropic/claude-sonnet-4-20250514",
messages=[{"role": "user", "content": "Hello!"}],
)
Streaming
stream = client.chat.completions.create(
model="openai/gpt-4o",
messages=[{"role": "user", "content": "Write a poem"}],
stream=True,
)
for chunk in stream:
print(chunk.choices[0].delta.content or "", end="")
Environment Variables
| Variable | Description |
|---|---|
HYPERROUTER_API_KEY |
API key (starts with mr-) |
HYPERROUTER_BASE_URL |
Custom base URL (default: https://api.hyperrouter.ai/v1) |
HyperRouter-Specific Methods
# Get detailed metadata for a request
generation = client.get_generation(trace_id="xxx")
print(generation.total_cost, generation.latency_ms)
# Check account balance
balance = client.get_balance()
print(balance.balance)
License
MIT
Metadata
Release files for hyperrouter-python 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hyperrouter_python-0.1.1.tar.gz | 3.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hyperrouter_python-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 8.4 kB
Release files / hyperrouter_python-0.1.1.tar.gz
| Download URL | hyperrouter_python-0.1.1.tar.gz |
|---|---|
| Size | 3.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
db34ad87b84db757e3b95cb67743198c7c0498a65fa19af9e6cc30497a094f61
|
|
BLAKE2b-256 checksum How to use checksums |
e67f088f369e3166d3afc45a4dd37448e05153a344956e5d770183100bd9e77f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / hyperrouter_python-0.1.1-py3-none-any.whl
| Download URL | hyperrouter_python-0.1.1-py3-none-any.whl |
|---|---|
| Size | 4.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
efdbb5f438ebae7bc6d2757a0c2254dc2a7964b571975f6032b5c7f1c285bf4a
|
|
BLAKE2b-256 checksum How to use checksums |
f2796c01cf4f6a8508fd7b0e79a441607a915d02421977a09b33befaca032047
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|