Use from Python
Soriku exposes an OpenAI-compatible endpoint, so the official `openai` SDK works as a drop-in client.
Install
pip install openai
Point it at Soriku
from openai import OpenAI
client = OpenAI(
base_url="http://localhost:8765/api/v1",
api_key="soriku-local" # ignored in local mode
)
resp = client.chat.completions.create(
model="auto", # let Soriku pick
messages=[{"role": "user", "content": "Explain monads in plain English."}]
)
print(resp.choices[0].message.content)
print("routed to:", resp.model)
Streaming
stream = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Write a haiku about routers."}],
stream=True
)
for chunk in stream:
delta = chunk.choices[0].delta.content
if delta:
print(delta, end="", flush=True)
Use a specific agent persona
resp = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Review this code"}],
extra_body={"x_agent_id": "code-reviewer"}
)