SDKs · menu
Build
SDKs
Official zero-dependency clients for JavaScript and Python, with retries, timeouts, typed errors, and LangChain adapters. You can also skip them entirely, since any OpenAI-compatible SDK works against the gateway.
You don't need an Arbr SDK. Point the OpenAI SDK's base_url at your Arbr instance and every call gains routing, logging, and budgets (see the OpenAI-compatible endpoint). The clients below add first-class attribution and the native endpoint's richer response.
JavaScript: arbr-client
Node ≥ 18, zero dependencies.
npm install arbr-clientimport { createClient } from "arbr-client";
const arbr = createClient({
baseUrl: "https://arbr.yourcompany.com",
apiKey: "ab_your_gateway_key",
application: "support-chat", // attribution on every call
});
const res = await arbr.chat({
messages: "Summarise: my card was declined at checkout.",
model: "auto",
});
console.log(res.text, res.model, res.routingDecision);Methods: chat(), stream(), models(), taskTypes(), embeddings(), status(). Errors throw a GatewayError with a stable code. For LangChain, arbr.asLangChainModel() returns a drop-in chat model.
Python: arbr-client
Python ≥ 3.11, standard library only, sync and async.
pip install arbr-client # or: pip install "arbr-client[langchain]"from arbr_client import create_client
arbr = create_client(
base_url="https://arbr.yourcompany.com",
api_key="ab_your_gateway_key",
application="support-chat",
)
res = arbr.chat(messages="Summarise: my card was declined.", model="auto")
print(res.text, res.model, res.routing_decision)Every method has an async twin: achat, astream, amodels, aembeddings, astatus. Responses are frozen dataclasses (ChatResponse carries text, model, routing_decision, usage, and more). For LangChain, use ArbrChatModel or as_langchain_model().
Streaming
for chunk in arbr.stream(messages="Write a haiku about routing.", model="auto"):
print(chunk, end="", flush=True)Client configuration
Both clients accept the same core options, and read sensible defaults from the environment (ARBR_GATEWAY_URL, ARBR_API_KEY, ARBR_USER_ID):
| Option | Purpose |
|---|---|
baseUrl / base_url | Your Arbr instance URL. |
apiKey / api_key | Gateway key (ab_...). Optional until Require API keys is on. |
application, workflow, department, userId | Attribution attached to every call. |
timeoutMs / timeout_s, retries | Request timeout and retry count. |
Every method signature and error code is documented per language. See JavaScript ↗ and Python ↗.