Official OpenAI SDKs (Python / Go / Java …) against compatible endpoints
When RouterBrain exposes /v1/chat/completions and related OpenAI-compatible routes, any client that supports base_url + api_key can point at the same Base URL without @routerbrain/sdk (for Node/TS the SDK is still recommended for types and multimodal helpers).
Common settings
| Setting | Value |
|---|---|
| Base URL | https://<your-host>/v1 (watch trailing slash rules vs client URL joining) |
| API Key | Tenant sk-… |
| Model | Exact code from GET /v1/models |
Smoke-test /v1/models and /v1/chat/completions with curl before the SDK to separate network/TLS from client config.
Python (openai package, illustrative)
Names and parameters depend on your installed version:
from openai import OpenAI
client = OpenAI(
base_url="https://gw.example.com/v1",
api_key="sk-…",
)
resp = client.chat.completions.create(
model="openai/gpt-4o-mini",
messages=[{"role": "user", "content": "ping"}],
)
print(resp.choices[0].message.content)
Streaming: use stream=True and chunk iterators per docs; mind proxies and SSE (Troubleshooting).
When to prefer @routerbrain/sdk
- Assemble
input_file, audio parts, etc. from local paths / URLs on Node; - Want
plugins.pdf→pdf_preprocessmerged automatically; - Want unified
GatewayHttpErrorhandling.
See chat.messages.
LangChain, LlamaIndex, LiteLLM, etc.
These usually accept OpenAI-compatible base_url / api_key: point at …/v1, model id = code from GET /v1/models. Field names differ by framework—check their docs on upgrades.
Checklist: Base URL includes /v1; streaming uses SSE (no proxy buffering—Troubleshooting); tool calls may hit unsupported extensions (400/501). Multimodal needs input_file—Chat Completions.