Python SDK
`brime` — sync + async Python client.
The official Python SDK for Brime. Sync (Brime) and async (AsyncBrime) clients sharing the same surface; httpx + pydantic v2; ships py.typed.
pip install brimeQuickstart
from brime import Brime
client = Brime(api_key="sk-brime-...")
result = client.search(query="Tesla Cybertruck recall 2025")
print(result.answer)import asyncio
from brime import AsyncBrime
async def main():
async with AsyncBrime() as client: # uses BRIME_API_KEY
result = await client.search(query="...")
print(result.answer)
asyncio.run(main())API
Brime(api_key=None, base_url=None, timeout=30.0)
Constructor. api_key falls back to BRIME_API_KEY env var; base_url falls back to BRIME_BASE_URL then https://api.brime.dev.
client.search(query, *, topic, max_results, time_range, ...) → SearchResponse
See the Search reference for parameter details. The historical depth kwarg is still accepted for backward compat but ignored by the gateway.
client.extract(urls, *, include_metadata, idempotency_key) → ExtractResponse
urls accepts a single string or a list. Auto-generates an Idempotency-Key.
client.research(query, *, topic, max_results, time_range, stream) → ResearchBasicResponse
Returns the synthesised answer + ranked sources after the tuned multi-round flow (~30–90 s wall-clock). The historical depth, max_rounds, wait, poll_interval, poll_timeout kwargs are still accepted for backward compat but ignored.
client.research_status(job_id) → ResearchStatusResponse
Polls an in-flight research job. Used by long-running legacy jobs; new calls return sync.
client.research_stream(query, *, last_event_id) → Iterator[ResearchSseEvent]
Yields parsed SSE events:
for event in client.research_stream(query="..."):
print(event.event, event.data)
if event.event in ("complete", "error", "timeout"):
breakErrors
from brime import (
BrimeError,
AuthenticationError,
RateLimitError,
InsufficientCreditsError,
InvalidRequestError,
NotFoundError,
UpstreamError,
InternalError,
)
try:
client.search(query="...")
except AuthenticationError:
...
except BrimeError as e:
print(e.code, e.status, e.message)See Errors for the full code catalog and retry guidance.
Configuration reference
| Constructor arg | Env var | Default |
|---|---|---|
api_key | BRIME_API_KEY | — (required) |
base_url | BRIME_BASE_URL | https://api.brime.dev |
timeout | — | 30.0 seconds |
Per-call timeouts override the constructor: client.search(..., timeout=60).