Client SDK for the routewise cost-aware LLM router
Project description
routewise (Python SDK)
Thin client for the routewise cost-aware LLM router. No routing logic lives here -- it's a convenience wrapper around HTTP calls to the real API.
Install
pip install routewise
Quick start
from routewise import RouteWiseClient
client = RouteWiseClient(api_key="rw_your_key_here")
result = client.ask("What is the capital of France?")
print(result["response"])
print(result["routed_to"], result["cost_usd"])
Bring your own model
Override any tier with your own provider and model. Unset tiers fall back to defaults automatically.
# set custom models for any combination of tiers
client.configure(
cheap={"provider": "groq", "model_id": "llama-3.1-8b-instant", "api_key": "your-groq-key"},
frontier={"provider": "openai", "model_id": "gpt-4o", "api_key": "your-openai-key"},
# mid not set -- uses default
)
# api keys are stored in memory and sent automatically with every ask()
result = client.ask("Design a distributed rate limiter")
print(result["response"])
All methods
# routing
client.ask("query") # auto-route by difficulty
client.ask("query", override_tier="frontier") # force a specific tier
client.ask("query", user_api_keys={"frontier": "sk-..."}) # per-request key override
# byom config
client.configure(cheap={...}, mid={...}, frontier={...}) # set custom models
client.get_config() # see currently active config (no keys returned)
client.get_providers() # list all supported providers + models
client.reset() # revert all tiers to defaults, clears in-memory keys
# stats
client.stats() # total requests, cost saved, tier distribution, etc.
Supported providers
providers = client.get_providers()
# returns: groq, openai, anthropic, gemini, deepseek, perplexity, mistral, xai, ollama
# each with a list of known models + "custom" option
Errors
| Exception | When |
|---|---|
RouteWiseError |
Base class for all errors |
ValidationError |
Bad input — empty query, unsupported provider, invalid model (400) |
AuthError |
Invalid/missing API key or rate limit hit (401/429) |
AllTiersFailedError |
Every provider tier failed, no response returned (503) |
from routewise import RouteWiseClient, ValidationError, AuthError, AllTiersFailedError
try:
result = client.ask("hello")
except AllTiersFailedError:
print("all providers down")
except AuthError:
print("check your api key")
except ValidationError as e:
print(f"bad request: {e}")
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
routewise-0.4.0.tar.gz
(5.6 kB
view details)
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 routewise-0.4.0.tar.gz.
File metadata
- Download URL: routewise-0.4.0.tar.gz
- Upload date:
- Size: 5.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e2b24997a1d151e58434c8dc7c995c1beb9a235709a7f30ac1bd559e28107374
|
|
| MD5 |
ccc1d9b128f9bff312f6961a174ccf45
|
|
| BLAKE2b-256 |
771dabd252cd568739e7efaf2ad9c953fb0308bd51565de6ae8eab967b0532c3
|
File details
Details for the file routewise-0.4.0-py3-none-any.whl.
File metadata
- Download URL: routewise-0.4.0-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5ad9d53724bf2657c3846e1cce7174011dd96babd8e192d9838253de63c1638d
|
|
| MD5 |
263bd1da569dfae81583ed203c87cc4e
|
|
| BLAKE2b-256 |
da13732cdf928909957ed0a605846632d5b924b3962bf420131fe142aa4f220f
|