Skip to main content

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.3.0.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

routewise-0.3.0-py3-none-any.whl (5.8 kB view details)

Uploaded Python 3

File details

Details for the file routewise-0.3.0.tar.gz.

File metadata

  • Download URL: routewise-0.3.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

Hashes for routewise-0.3.0.tar.gz
Algorithm Hash digest
SHA256 0b0578cdec09909075bf8e6d9f2d03ddd76f8744486ee5412099fe8f776a7656
MD5 f6e2a7cb19dbfbfe356bc218c1daad37
BLAKE2b-256 7856b8ca2eef0e1a063f705c028ee9776e723d595a4a7558afaf0aab1265505a

See more details on using hashes here.

File details

Details for the file routewise-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: routewise-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 5.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.2

File hashes

Hashes for routewise-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ab421e81a130ba29cc73f721fe936371247c6c13d6ddf244186d68c2f6bde8e7
MD5 9e4e986fb9dbbace9caa62f326891b00
BLAKE2b-256 864c1ab01b50cc3067234d7fc3233d9e347ff6aaedbc7b8c67c1767d42b76932

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page