@bryel/browser traces AI-SDK calls that run in the browser — when your agent
issues model calls from client code rather than a server. Same OpenInference
spans as the server SDK, batched and non-blocking, with no app-boot cost.
If your model calls run on a server, use TypeScript instead — it adds nothing to your client bundle.
Create a browser key
In the dashboard, open Developer → API keys → Browser key and list the
origins your app runs on (e.g.
https://app.example.com). You get a
publishable bkp_… key: write-only and locked to those origins, so it is
safe to ship in client code.Why it won’t slow your app
- No app-boot cost. With
createBryelTraceryou build the tracer only where you trace; nothing runs at startup, and the package lazy-imports. - Non-blocking. Spans batch and POST in the background, off your request path — calls never wait on export, and export failures are swallowed.
- ~21 KB gzipped, all-in. Lazy-load it so it stays off your critical path.
Excluding traffic
Capture is per call. GateisEnabled on your own logic to skip a cohort — e.g.
isEnabled: tier !== "enterprise" — and those calls emit no spans; their data
never leaves the browser.
Global registration (optional)
If your app has no other OpenTelemetry setup, register a global provider and drop thetracer:
API
createBryelTracer(options): Tracer
Returns an OpenTelemetry Tracer to pass into experimental_telemetry.tracer.
No global registration — build it where you trace.
registerBryelBrowser(options): WebTracerProvider
Registers a global browser provider; returns it for forceFlush() / shutdown().
Options
A publishable key (
bkp_…) — write-only, origin-locked. Never a secret bk_ key.OTLP/HTTP endpoint. Override for self-hosting.
OpenTelemetry
service.name.Extra headers, merged after auth.