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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
brainstormrouter-0.1.0.tar.gz
(11.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file brainstormrouter-0.1.0.tar.gz.
File metadata
- Download URL: brainstormrouter-0.1.0.tar.gz
- Upload date:
- Size: 11.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0b3c30568a13afe7a3fb04f36822a5e712f7ea2c355ee87ecbda924d69882881
|
|
| MD5 |
9101a1ce22bec2b8cc8941b4215b36d1
|
|
| BLAKE2b-256 |
bf9cc004cd8b77cfdd83f129307da6488b88005e5aef7eeabb4fda24347eb0b7
|
File details
Details for the file brainstormrouter-0.1.0-py3-none-any.whl.
File metadata
- Download URL: brainstormrouter-0.1.0-py3-none-any.whl
- Upload date:
- Size: 15.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via:
twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e80a34cd95cc21e5b74cb327c5874b05615a9d768bc802b7545257064e57a0f6
|
|
| MD5 |
862acc1b8a50e34935eb414cb2e99746
|
|
| BLAKE2b-256 |
29f39d1d6b352a93d3c490b3c290fe036fa258f68223ff50e3f748bbe879f0ad
|