BrainstormRouter Python SDK
Drop-in replacement for the OpenAI Python SDK with intelligent routing, memory, guardrails, and governance across 247 model endpoints.
Install
pip install brainstormrouter
Quick Start
from brainstormrouter import BrainstormRouter
client = BrainstormRouter(api_key="brk_...")
# OpenAI-compatible — works with LangChain, LlamaIndex, CrewAI, etc.
response = client.chat.completions.create(
model="anthropic/claude-sonnet-4",
messages=[{"role": "user", "content": "Hello"}],
)
print(response.choices[0].message.content)
Use "auto" as the model to let BrainstormRouter's Thompson sampling pick the best model:
response = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Explain quantum computing"}],
)
Streaming
stream = client.chat.completions.create(
model="auto",
messages=[{"role": "user", "content": "Write a poem"}],
stream=True,
)
for chunk in stream:
content = chunk.choices[0].delta.content
if content:
print(content, end="")
Memory (4-Block RMM)
# Append a memory entry
client.memory.append("User prefers concise answers", block="semantic")
# List memory entries
result = client.memory.entries()
# List memory blocks with entry counts
result = client.memory.blocks()
# Bootstrap memory from documents
client.memory.init([{"content": "Product requirements doc...", "source": "prd.md"}])
Guardrails
# Test content against guardrail pipeline
result = client.guardrails.test(
content="Check this message for PII",
direction="inbound",
)
Provider Keys (BYOK)
# Register your own provider key
client.providers.register("anthropic", api_key="sk-ant-...")
# Validate a key with a live request
result = client.providers.test("anthropic", "sk-ant-...")
Configuration
client = BrainstormRouter(
api_key="brk_...", # or set BRAINSTORMROUTER_API_KEY env var
base_url="https://api.brainstormrouter.com", # default
)
Resources
License
MIT
Metadata
Release files for brainstormrouter 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| brainstormrouter-0.1.0.tar.gz | 11.8 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| brainstormrouter-0.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 26.9 kB
Release files / brainstormrouter-0.1.0.tar.gz
| Download URL | brainstormrouter-0.1.0.tar.gz |
|---|---|
| Size | 11.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0b3c30568a13afe7a3fb04f36822a5e712f7ea2c355ee87ecbda924d69882881
|
|
BLAKE2b-256 checksum How to use checksums |
bf9cc004cd8b77cfdd83f129307da6488b88005e5aef7eeabb4fda24347eb0b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|
Release files / brainstormrouter-0.1.0-py3-none-any.whl
| Download URL | brainstormrouter-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e80a34cd95cc21e5b74cb327c5874b05615a9d768bc802b7545257064e57a0f6
|
|
BLAKE2b-256 checksum How to use checksums |
29f39d1d6b352a93d3c490b3c290fe036fa258f68223ff50e3f748bbe879f0ad
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.9.6
|