Metadata-Version: 2.4
Name: hyperrouter-python
Version: 0.1.0
Summary: Official Python SDK for HyperRouter — AI model aggregation platform
Project-URL: Homepage, https://hyperrouter.ai
Project-URL: Documentation, https://hyperrouter.ai/docs
Project-URL: Repository, https://github.com/hyperrouter/python-sdk
Author-email: HyperRouter <support@hyperrouter.ai>
License-Expression: MIT
License-File: LICENSE
Keywords: ai,api,hyperrouter,llm,openai,sdk
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Typing :: Typed
Requires-Python: >=3.9
Requires-Dist: openai>=1.0.0
Requires-Dist: pydantic>=2.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio>=0.21.0; extra == 'dev'
Requires-Dist: pytest>=7.0; extra == 'dev'
Description-Content-Type: text/markdown

# HyperRouter Python SDK

Official Python SDK for [HyperRouter](https://hyperrouter.ai) — AI model aggregation platform.

## Installation

```bash
pip install hyperrouter
```

## Quick Start

```python
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

```python
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

```python
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

```python
# 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
