OpenAI Python SDK

Drop-in: change one line, route through HiWay.

The OpenAI Python SDK is the most common entry point. HiWay implements the same wire protocol, so your existing code keeps working - you just override the base_url and use your hw_live_ API key.

Minimal example

app.py
from openai import OpenAI

client = OpenAI(
    base_url="https://app.hiway2llm.com/v1",
    api_key="hw_live_YOUR_KEY",
)

response = client.chat.completions.create(
    model="auto",
    messages=[
        {"role": "system", "content": "You are a concise assistant."},
        {"role": "user", "content": "Summarise the French Revolution in 3 lines."},
    ],
)
print(response.choices[0].message.content)
print("Routed to:", response.model)

Streaming

python
stream = client.chat.completions.create(
    model="auto",
    messages=[{"role": "user", "content": "Count to ten slowly"}],
    stream=True,
)
for chunk in stream:
    if chunk.choices[0].delta.content:
        print(chunk.choices[0].delta.content, end="", flush=True)

Pin a specific model

Pass a fully-qualified model id to bypass routing and go straight to that model.

python
response = client.chat.completions.create(
    model="anthropic/claude-opus-4-7",  # pin this exact model
    messages=[{"role": "user", "content": "Critical query"}],
)

All chat-completions parameters are forwarded as-is - temperature, top_p, tools, tool_choice, response_format, max_tokens, stream, seed, etc.