Skip to main content

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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hiway2llm-0.1.0.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

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

hiway2llm-0.1.0-py3-none-any.whl (5.6 kB view details)

Uploaded Python 3

File details

Details for the file hiway2llm-0.1.0.tar.gz.

File metadata

  • Download URL: hiway2llm-0.1.0.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for hiway2llm-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6fab93846e2820f654652268e35f7694615db1c1905fc3219d7cf381cedcd6f5
MD5 e4adedde74a9e0645a5b8f67b5d8ed58
BLAKE2b-256 c97c5456712dd63520de575f51281cff8b918e4baad702651e77b718b03e1f89

See more details on using hashes here.

File details

Details for the file hiway2llm-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: hiway2llm-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 5.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.10

File hashes

Hashes for hiway2llm-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cf79c5ddb8a67ce8e49eff5288da01788ffb4e20e606ae8e5e48a11515ed247d
MD5 4d63bc4d152e616bde9d6b08a5ac3efa
BLAKE2b-256 82a5fa82547e8a7c448a618e3b858fb4efb41254c3d24c06301d816dc911ccdf

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