Skip to main content

KairosRoute Python SDK

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

Install

pip install kairosroute

Quick Start

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

# 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

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.")

Metadata

Release files for kairosroute 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kairosroute 0.1.0
File Size Uploaded
kairosroute-0.1.0.tar.gz 5.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kairosroute 0.1.0
File Interpreter ABI Platform
kairosroute-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 11.8 kB

Release files / kairosroute-0.1.0.tar.gz

Download URL kairosroute-0.1.0.tar.gz
Size 5.4 kB
Tags Source
SHA-256 checksum
How to use checksums
90b69dab3007970181f7118b70f8226515e9f728a5e491bcca01d2f64b3d4316
BLAKE2b-256 checksum
How to use checksums
71c5194c1bc98ec4ba18d4d635a16eeebaad0ba9a2a1de82d236d74b9396afae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release files / kairosroute-0.1.0-py3-none-any.whl

Download URL kairosroute-0.1.0-py3-none-any.whl
Size 6.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
9cb2b69913d81f0e73b6c28078187c50c0e1e20f35bd23583f5eacce657e62c5
BLAKE2b-256 checksum
How to use checksums
7220321a7adbb6d0cfce9fe9468497f433a960dcf5bd4663a95d271d5a1fb85b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.3

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page