The API is OpenAI-compatible. If your code already talks to
/v1/chat/completions, integrating a cognitive is a base URL, a key, and a model id — no new SDK.Authentication
Create a developer API key from your dashboard. It's shown once, stored only as a SHA-256 hash, and can be revoked at any time; the platform records a last-used timestamp but can never recover the key itself. Losing it means issuing a new one.
Send it as a bearer token. Your API base URL and a cognitive's model id both come from the Use this chat via API panel in the chat view — grab them from there rather than hardcoding a host:
bash
export BR_API_BASE="<base URL from the API panel>"
curl "$BR_API_BASE/v1/chat/completions" \
-H "Authorization: Bearer sk_live_..." \
-H "Content-Type: application/json" \
-d '{
"model": "cognitive/<profile_id>",
"messages": [{"role": "user", "content": "How would you price a second tier?"}]
}'Auth failures return 401 with a deliberately generic message — an unknown key, a revoked key, and an inactive account are indistinguishable by design, so don't try to branch on the reason.
Addressing a cognitive
The
model field is the cognitive's profile id. A cognitive/ or cognitive: prefix is accepted and stripped, so both of these work:json
{ "model": "cognitive/8f2c...", "messages": [...] }
{ "model": "8f2c...", "messages": [...] }To run several cognitives in one call, pass a comma-separated list. Each contributes its reasoning to the same turn, and each seller earns at their own rate:
json
{ "model": "cognitive/8f2c...,cognitive/41ab...", "messages": [...] }GET /v1/models lists what the key can address, so you don't need to hardcode ids.Using the OpenAI SDK
Point the client at the platform and everything else stays the same:
python
import os
from openai import OpenAI
client = OpenAI(
api_key=os.environ["BR_API_KEY"], # sk_live_...
base_url=f"{os.environ['BR_API_BASE']}/v1",
)
resp = client.chat.completions.create(
model="cognitive/<profile_id>",
messages=[{"role": "user", "content": "Review this rollout plan."}],
)
print(resp.choices[0].message.content)Streaming works through the same interface with
stream=True, delivering content deltas and a final usage payload.Rate limits and retries
Requests are limited to 60 per minute per account, counted in a sliding window across all keys on that account. Over the limit returns 429 with a retryable message.
Two things to get right in production:
Back off, don't hammer. Exponential backoff with jitter on 429. A tight retry loop from several workers will keep you pinned at the limit.
Budget for latency. A turn can involve multiple internal model calls, tool use, and web fetches, so it is not a single-shot completion. Set client timeouts generously and prefer streaming for anything user-facing, so the first tokens arrive while the rest of the turn is still working.
Billing and observability
Usage through a key is billed to that key's owning account from the same prepaid wallet as web chat: the model cost as a pass-through, plus each active cognitive's rate applied to output tokens. API turns show up in Usage Logs like any other turn, tagged with their source, so a spike in spend is attributable.
Two operational habits worth adopting early: set a low-balance threshold so a drained wallet doesn't surface as failing requests in production, and use a separate key per service so you can revoke one without taking down the rest.
A checklist before you ship
- Key in a secret manager, never in the repo; one key per service.
- 429 handled with jittered exponential backoff.
- Client timeout well above your slowest observed turn; streaming for user-facing paths.
- Model ids fetched from
/v1/modelsrather than hardcoded. - Low-balance alerting wired to something a human reads.
- Usage Logs checked after your first day of real traffic — cost per turn is easy to underestimate when the agent uses tools heavily.