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
Metadata
Release files for hiway2llm 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| hiway2llm-0.1.1.tar.gz | 5.1 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| hiway2llm-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 10.7 kB
Release files / hiway2llm-0.1.1.tar.gz
| Download URL | hiway2llm-0.1.1.tar.gz |
|---|---|
| Size | 5.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
34704252a5ce8391996cd3de99ff5c539acbfe11835fb74e7afb0a9771f2d8d2
|
|
BLAKE2b-256 checksum How to use checksums |
cadabf3a84ccd03462238fbb75bb09bfca3c470cd924f5a578afe1cdbb29d7b3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|
Release files / hiway2llm-0.1.1-py3-none-any.whl
| Download URL | hiway2llm-0.1.1-py3-none-any.whl |
|---|---|
| Size | 5.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8ade31d8fcf4d7932024bb0dae5a1f6023826dc6860d4a3c2583e52ffd0fa837
|
|
BLAKE2b-256 checksum How to use checksums |
2dd523b9543afb12d7f379c9bf407bdf3c7be02037518b44c80ad077d43cce73
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is 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}
|