Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hyperrouter_python-0.1.0.tar.gz (3.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hyperrouter_python-0.1.0-py3-none-any.whl (4.4 kB view details)

Uploaded Python 3

File details

Details for the file hyperrouter_python-0.1.0.tar.gz.

File metadata

  • Download URL: hyperrouter_python-0.1.0.tar.gz
  • Upload date:
  • Size: 3.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.6

File hashes

Hashes for hyperrouter_python-0.1.0.tar.gz
Algorithm Hash digest
SHA256 a2a333f3577f095fa72d3dfe62c8668730b5903dfe2e8119c03d664fa75b14d5
MD5 1b77826d50afe333cec21f829810e984
BLAKE2b-256 1ac372b519d053f42ed6920e9f8d6d005928e1b93e4d73063f9af040bd807197

See more details on using hashes here.

File details

Details for the file hyperrouter_python-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hyperrouter_python-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 61fec20ded63cef237f700071e605ad29ce15ea6e5e8d41f761c1bc90e8e6a84
MD5 70697bb1e8872f02d7493e5590347c68
BLAKE2b-256 b16eb55bd96ba4b275bae64b66eada061531e46b8d18aab75f6a58f48bb44964

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page