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.2.0.tar.gz
(4.0 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.2.0.tar.gz.
File metadata
- Download URL: routewise-0.2.0.tar.gz
- Upload date:
- Size: 4.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a88b8f0729d4aeb30c75e4b0e5485b0d389a748479be5849a4d46f993fdd63a
|
|
| MD5 |
62d97a832ecf0026a894d07e3257e358
|
|
| BLAKE2b-256 |
d25676526706ee5e5c9fffc3d32737d198d907b562ac9e6793c38cccfbafd428
|
File details
Details for the file routewise-0.2.0-py3-none-any.whl.
File metadata
- Download URL: routewise-0.2.0-py3-none-any.whl
- Upload date:
- Size: 4.2 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 |
ddea3f250f3413b52be75ca33c830450b90d850bebc17a8f9f73900fae263bf2
|
|
| MD5 |
ba3ae7976a0dd12b31fc428ea32443c6
|
|
| BLAKE2b-256 |
8426cd37646aadbba140a32500314e69642db996b59e139bca1db8065ca39b1c
|