Skip to main content
API reference for the browser SDK’s exports and options. For end-to-end setup, see the Browser guide.

Install

bun add @bryel/browser

createBryelTracer

createBryelTracer(options): Tracer
Returns an OpenTelemetry Tracer to pass into the AI SDK’s experimental_telemetry.tracer. No global registration — build it where you trace, so there is no app-boot cost.
import { createBryelTracer } from "@bryel/browser";

const tracer = createBryelTracer({ apiKey: "bkp_…", serviceName: "studio-agent" });

await streamText({
  model,
  experimental_telemetry: { isEnabled: true, tracer, metadata: { sessionId, userId } },
  prompt,
});

registerBryelBrowser

registerBryelBrowser(options): WebTracerProvider
Registers a global browser tracer provider. Use only when the app has no other OpenTelemetry setup; then experimental_telemetry: { isEnabled: true } (without a tracer) routes through bryel. Returns the provider so you can forceFlush() / shutdown() on unload.

Options

Both functions take the same options.
apiKey
string
required
A publishable key (bkp_…) — write-only and origin-locked. Never a secret bk_ key; a browser bundle is public.
endpoint
string
default:"https://ingest.eu.bryel.ai/v1/traces"
OTLP/HTTP traces endpoint. Override for self-hosting.
serviceName
string
OpenTelemetry service.name stamped on the resource.
headers
Record<string, string>
Extra headers, merged after the auth header.

Telemetry metadata

The same metadata fields as the server SDK group and join your data:
sessionId
string
Groups multiple calls into one conversation.
userId
string
The end user behind the run.
messageId
string
A per-turn id you mint, used to attach feedback.
The browser SDK reuses the @bryel/vercel mapper, so a browser-emitted span lands in bryel identically to a server one.