@bryel/browser traces AI-SDK calls that run in the browser — when your agent issues model calls from client code rather than a server. It ships the same OpenInference spans as the server SDK, batched and non-blocking, with no app-boot cost.
If your model calls run on a server (Next.js route handlers, server actions), use
@bryel/vercel instead — it adds nothing to your client bundle.Create a browser key
In the dashboard, open Settings → 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.Create a tracer and pass it per call
Build the tracer where you trace — not at app boot — and hand it to the AI SDK. Spans flush in the background.
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 (never thrown into your app).
- ~21 KB gzipped, all-in. Lazy-load it so it stays off your critical boot 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 at all; their data never leaves the browser.
Global registration (optional)
If your app has no other OpenTelemetry setup, register a global provider and drop thetracer:
@bryel/browser reference.