Skip to content
GitHubLog inStart free
cetra is not released yet. These docs describe the development version.

TypeScript SDK

Use the TypeScript SDK to send traces and scores from Node, Bun, Deno or an edge runtime to cetra. The @cetra-ai/sdk package (MIT, ESM only) is a thin layer over OpenTelemetry: tracing goes out as OTLP/HTTP protobuf, and scores and feedback go over a small REST surface. It runs on Node 22.12 or later, Bun, Deno and edge runtimes, with one fetch-based transport everywhere.

The pages of this reference:

  • Tracing: observe, withSpan and withLlmSpan.
  • Context: sessions, users, tags and metadata, and baggage.
  • Scores, datasets and experiments: score, the Client and evaluate.
  • OpenTelemetry: instrumentation helpers, the Vercel AI SDK, existing OpenTelemetry setups and masking.
  • Runtimes: edge runtimes, serverless, browser feedback and known limits.
  • API: every export.
Terminal window
pnpm add @cetra-ai/sdk

The instrumentation helpers need their OpenInference packages (optional peers, installed next to the SDK):

Terminal window
pnpm add @arizeai/openinference-instrumentation-openai openai

For a first trace, follow the quick start.

init() is once per process: a second call logs one warning and changes nothing. Without an API key (argument and CETRA_API_KEY both unset) it warns once and runs disabled; CETRA_ENABLED=false silences the warning.

Option Env Default
apiKey CETRA_API_KEY unset: one warning, SDK disabled
baseUrl CETRA_BASE_URL http://localhost:8080
environment CETRA_ENVIRONMENT unset
release CETRA_RELEASE unset
captureContent CETRA_CAPTURE_CONTENT true
sampleRate CETRA_SAMPLE_RATE 1 (trace-id ratio sampler)
useGlobalProvider — false
instrument — []
mask — none
exportFilter — none
enabled CETRA_ENABLED true (no-op mode when false)

An explicit argument wins over the env var, which wins over the default. Env values are trimmed; an empty value counts as unset. An invalid value throws a ConfigError naming the option, never its value. OTEL_SERVICE_NAME (from the config’s env source) sets service.name.

Logs and warnings never contain payloads (prompts, completions, attribute values), API keys or email addresses: ids, sizes and counts only. An invalid score logs cetra: score not queued: <reason> with the reason, never the value. The API key never appears in errors or serialized config.

Every request the SDK sends carries User-Agent: cetra-sdk-js/<version>: trace exports, score writes, prompt fetches and Client calls. Nothing else goes into it. A firewall or proxy in front of cetra can allow this value. The browser feedback() helper sends the browser’s own user agent.