LangChain

Point LangChain at HiWay with one base_url change.

LangChain uses the OpenAI-compatible client under the hood. To route a LangChain chain through HiWay, override base_url and use your hwy_ key.

chain.py
from langchain_openai import ChatOpenAI

llm = ChatOpenAI(
    model="auto",
    base_url="https://www.hiway2llm.com/v1",
    api_key="hwy_YOUR_KEY",
)

response = llm.invoke("Summarize this article in 3 bullets: ...")
print(response.content)

Tool calling works

HiWay forwards tool/function calls transparently. Your LangChain tools, output parsers, and structured outputs keep working exactly as before.

Choosing a tier per chain

For RAG retrievers and routing chains, pin model="light" — the router short-circuits and sends the request to the cheapest tier. For generation chains where quality matters, use model="auto" and let the router decide per message.