Official Python SDK for HyperRouter — AI model aggregation platform
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file hyperrouter_python-0.1.1.tar.gz.
File metadata
- Download URL: hyperrouter_python-0.1.1.tar.gz
- Upload date:
- Size: 3.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
db34ad87b84db757e3b95cb67743198c7c0498a65fa19af9e6cc30497a094f61
|
|
| MD5 |
64053f99890dd60f33845e57f8c3cbf9
|
|
| BLAKE2b-256 |
e67f088f369e3166d3afc45a4dd37448e05153a344956e5d770183100bd9e77f
|
File details
Details for the file hyperrouter_python-0.1.1-py3-none-any.whl.
File metadata
- Download URL: hyperrouter_python-0.1.1-py3-none-any.whl
- Upload date:
- Size: 4.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
efdbb5f438ebae7bc6d2757a0c2254dc2a7964b571975f6032b5c7f1c285bf4a
|
|
| MD5 |
fcd9b71a86c82075b7b7ebaa1738aa0d
|
|
| BLAKE2b-256 |
f2796c01cf4f6a8508fd7b0e79a441607a915d02421977a09b33befaca032047
|