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,withSpanandwithLlmSpan. - Context: sessions, users, tags and metadata, and baggage.
- Scores, datasets and experiments:
score, theClientandevaluate. - OpenTelemetry: instrumentation helpers, the Vercel AI SDK, existing OpenTelemetry setups and masking.
- Runtimes: edge runtimes, serverless, browser feedback and known limits.
- API: every export.
Install
Section titled “Install”pnpm add @cetra-ai/sdkThe instrumentation helpers need their OpenInference packages (optional peers, installed next to the SDK):
pnpm add @arizeai/openinference-instrumentation-openai openaiInitialize
Section titled “Initialize”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.
Configuration
Section titled “Configuration”| 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.
What is never logged
Section titled “What is never logged”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.
User agent
Section titled “User agent”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.