Official SDKs for JavaScript, Python and PHP
Install boldrouter with npm, pip or Composer. The SDKs come set up for boldrouter, take routing, fallback and anonymization as typed options, and tell you which provider answered.
> SDKs
boldrouter now has official libraries for the three languages most of our users write in:
| Language | Install |
|---|---|
| JavaScript / TypeScript | npm install boldrouter |
| Python | pip install boldrouter |
| PHP | composer require boldrouter/boldrouter |
They read your key from BOLDROUTER_API_KEY and point at boldrouter without any setup. The requests and responses are the ones of the OpenAI API, so code you already have keeps working.
Routing options as parameters
The options that make boldrouter more than a proxy are ordinary parameters, and the reply tells you who served it:
from boldrouter import BoldRouter
client = BoldRouter()
r = client.bold.chat(
model="anthropic/claude-sonnet-4.6",
messages=[{"role": "user", "content": "Summarize this clause..."}],
# the cheapest healthy provider:
routing="price",
# if Claude fails, try these models:
models=["openai/gpt-5.5", "google/gemini-3.5-flash"],
# remove personal data before it leaves boldrouter:
anonymize=True,
)
print(r.text, r.provider)The same call exists in JavaScript (client.bold.chat({...})) and PHP ($client->bold->chat([...])). There is also bold.models() for the catalog and bold.compare() to send one prompt to several models side by side.
Built for production
- Retries: rate limits and server errors are retried with backoff before you see them.
- Typed errors: an unknown model, missing credit or a bad key each raise their own error, so you can handle them separately.
- Streaming: text arrives as the model writes it. The JavaScript and Python SDKs use the official OpenAI libraries underneath, so streaming, tools and structured outputs work exactly as there. The PHP SDK streams over curl, so text is not held back until the end.
We tested each SDK against the live gateway with routing, failover, streaming, tool calls, structured output, image input and embeddings.
Get started
The SDKs page in the docs has the install steps, streaming, all options and error handling for each language. Using a framework instead? The Vercel AI SDK provider, the n8n node and the Langflow extension are listed there too.