HiWay2LLM SDK (Python) — OpenAI-compatible client for the HiWay router. BYOK, 40-60% savings, 0% markup on inference.
Project description
hiway2llm
Official Python SDK for HiWay2LLM — BYOK smart LLM routing with 40-60 % savings and zero markup on inference.
Install
pip install hiway2llm
Or with uv:
uv add hiway2llm
Works on Python 3.9+. Pulls in httpx (the only runtime dep).
Quickstart
import os
from hiway2llm import Hiway
h = Hiway(api_key=os.environ["HIWAY_API_KEY"])
res = h.chat.completions.create(
model="auto", # smart routing
messages=[{"role": "user", "content": "Say hi"}],
)
print(res["choices"][0]["message"]["content"])
print(res["_hiway"]["routed_model"]) # which model was picked
Already using the OpenAI SDK? You can keep it — just change base_url:
from openai import OpenAI
client = OpenAI(
api_key=os.environ["HIWAY_API_KEY"], # hw_live_...
base_url="https://app.hiway2llm.com/v1",
)
Both approaches hit the same OpenAI-compatible endpoint.
API surface
| Method | Description |
|---|---|
h.chat.completions.create(model=..., messages=..., **opts) |
OpenAI-compatible chat completion. |
h.models.list() |
Models your workspace can route to (BYOK-filtered). |
h.me() |
Current user + plan. |
Errors
All 4xx / 5xx responses raise HiwayError with .status + .body:
from hiway2llm import Hiway, HiwayError
h = Hiway()
try:
h.chat.completions.create(model="auto", messages=[{"role": "user", "content": "hi"}])
except HiwayError as e:
if e.status == 402:
# quota exhausted — prompt to upgrade
...
Links
License
MIT — © Mytm-Group SAS
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
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 hiway2llm-0.1.1.tar.gz.
File metadata
- Download URL: hiway2llm-0.1.1.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
34704252a5ce8391996cd3de99ff5c539acbfe11835fb74e7afb0a9771f2d8d2
|
|
| MD5 |
e7dd238c0cae2e5c42dc733de30e1f93
|
|
| BLAKE2b-256 |
cadabf3a84ccd03462238fbb75bb09bfca3c470cd924f5a578afe1cdbb29d7b3
|
File details
Details for the file hiway2llm-0.1.1-py3-none-any.whl.
File metadata
- Download URL: hiway2llm-0.1.1-py3-none-any.whl
- Upload date:
- Size: 5.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.11.2 {"installer":{"name":"uv","version":"0.11.2","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ade31d8fcf4d7932024bb0dae5a1f6023826dc6860d4a3c2583e52ffd0fa837
|
|
| MD5 |
791e6c1e7c03a04f9e8128b0aea6b27d
|
|
| BLAKE2b-256 |
2dd523b9543afb12d7f379c9bf407bdf3c7be02037518b44c80ad077d43cce73
|