Langfuse
Send BrainstormRouter observability data to Langfuse for tracing and analytics.
Overview
BrainstormRouter's observability engine can broadcast events directly to Langfuse via OTLP. Every completion, error, and memory operation flows into Langfuse traces.
Setup
1. Get Langfuse credentials
From your Langfuse dashboard, get your:
- Public key
- Secret key
- Host URL (default:
https://cloud.langfuse.com)
2. Add OTLP destination
import BrainstormRouter from "brainstormrouter";
const client = new BrainstormRouter({ apiKey: "br_live_..." });
await client.observability.addDestination({
name: "Langfuse",
type: "otlp",
config: {
endpoint: "https://cloud.langfuse.com/api/public/ingestion",
headers: {
"X-Langfuse-Public-Key": "pk-...",
"X-Langfuse-Secret-Key": "sk-...",
},
},
event_types: ["usage", "quality", "error"],
});
await client.observability.setEnabled(true);
curl
curl -X POST https://api.brainstormrouter.com/v1/observability/destinations \
-H "Authorization: Bearer br_live_..." \
-H "Content-Type: application/json" \
-d '{
"name": "Langfuse",
"type": "otlp",
"config": {
"endpoint": "https://cloud.langfuse.com/api/public/ingestion",
"headers": {
"X-Langfuse-Public-Key": "pk-...",
"X-Langfuse-Secret-Key": "sk-..."
}
},
"event_types": ["usage", "quality", "error"]
}'
3. Test the connection
const destinations = await client.observability.destinations();
const langfuse = destinations.destinations.find((d) => d.name === "Langfuse");
await client.observability.testDestination(langfuse!.id);
What you get in Langfuse
| BrainstormRouter event | Langfuse trace |
|---|---|
usage | Generation trace with model, tokens, cost, latency |
quality | Score attached to trace (tool-call accuracy) |
error | Error event with provider, status, message |
guardrail | Span with safety scan results |
audit | Memory operation logged as observation |
Memory events (unique)
BrainstormRouter is the only gateway that sends memory operation events to Langfuse. Track what the agent learns:
audit:append— new fact storedaudit:replace— fact updatedaudit:delete— fact removedaudit:evict— fact evicted by sleep-time
This enables Langfuse dashboards that show memory growth, PII incidents, and sleep-time refinement activity over time.
Batching
For high-throughput workloads, add batching to reduce HTTP overhead:
await client.observability.addDestination({
name: "Langfuse",
type: "otlp",
config: { endpoint: "...", headers: { ... } },
batch: { max_size: 100, flush_interval_ms: 10000 },
});