Arbr Docs
← Home Star on GitHub
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.

The base-URL swap

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.

sh
npm install arbr-client
js
import { 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.

sh
pip install arbr-client            # or: pip install "arbr-client[langchain]"
python
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

python
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):

OptionPurpose
baseUrl / base_urlYour Arbr instance URL.
apiKey / api_keyGateway key (ab_...). Optional until Require API keys is on.
application, workflow, department, userIdAttribution attached to every call.
timeoutMs / timeout_s, retriesRequest timeout and retry count.
Full reference

Every method signature and error code is documented per language. See JavaScript ↗ and Python ↗.