Metadata-Version: 2.4
Name: kairosroute
Version: 0.1.0
Summary: KairosRoute Python SDK — AI API broker with intelligent model routing
Author-email: KairosRoute <support@kairosroute.com>
License: MIT
Project-URL: Homepage, https://kairosroute.com
Project-URL: Documentation, https://kairosroute.com/docs
Project-URL: Repository, https://github.com/kairosroute/kairosroute-python
Project-URL: Bug Tracker, https://github.com/kairosroute/kairosroute-python/issues
Keywords: ai,api,llm,openai,routing,broker,kairosroute
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: Topic :: Software Development :: Libraries :: Python Modules
Classifier: Typing :: Typed
Requires-Python: >=3.9
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: httpx>=0.25.0
Dynamic: license-file

# KairosRoute Python SDK

Drop-in replacement for the OpenAI Python client with intelligent model routing and cost optimization.

## Install

```bash
pip install kairosroute
```

## Quick Start

```python
from kairosroute import KairosRoute

client = KairosRoute(api_key="kr_live_...")

# Chat completions (same API as OpenAI)
response = client.chat.completions.create(
    model="kr-auto",  # auto-routes to cheapest model meeting quality threshold
    messages=[{"role": "user", "content": "Explain quantum computing in one sentence"}],
)
print(response["choices"][0]["message"]["content"])

# Embeddings
embeddings = client.embeddings.create(
    input="Hello world",
    model="kr-auto-embed",
)
print(f"Dimensions: {len(embeddings['data'][0]['embedding'])}")

# Streaming
for chunk in client.chat.completions.create(
    model="kr-auto",
    messages=[{"role": "user", "content": "Write a haiku"}],
    stream=True,
):
    if chunk.get("choices"):
        delta = chunk["choices"][0].get("delta", {})
        print(delta.get("content", ""), end="", flush=True)
```

## Migration from OpenAI

```python
# Before
from openai import OpenAI
client = OpenAI(api_key="sk-...")

# After
from kairosroute import KairosRoute
client = KairosRoute(api_key="kr_live_...")

# Everything else stays the same
```

## Error Handling

```python
from kairosroute import KairosRoute, RateLimitError, BudgetExceededError

client = KairosRoute(api_key="kr_live_...")

try:
    response = client.chat.completions.create(
        model="kr-auto",
        messages=[{"role": "user", "content": "Hello"}],
    )
except RateLimitError as e:
    print(f"Rate limited. Retry after {e.retry_after}s")
except BudgetExceededError:
    print("Daily budget exceeded. Upgrade to Pro.")
```
