Skip to main content

Installation

Quick Start

Track agent releases

Give each agent version a stable release label and environment when starting a run:
Use your own deployment version or commit identifier. The release label accepts up to 128 characters: letters, digits, ., _, /, @, :, +, and -, starting with a letter or digit. The environment accepts up to 64 characters: letters, digits, ., _, and -, also starting with a letter or digit. Labels are case-sensitive; keep credentials and personal data out of them. The session page shows the recorded release and its history. Changing a release or environment during a run leaves that run mixed. Adding a label after unlabeled activity leaves it partly recorded. Start a new run for a new release. An SDK version or model name is not an agent release. This uses the metadata supported by SDK 0.8.1; it requires the release-attribution API deployment. Older runs remain available for inspection, but their final metadata is not backfilled into a release history. Release labels identify runs; they do not establish that a version improved outcomes. To compare evaluations before and after a deployment, follow Compare agent releases. It covers shared measurements, UTC observation windows, coverage requirements and saved source evidence.

SentrialClient

constructor(config)

createSession(params)

Create a new tracking session. Returns string | null (null when failSilently is true and the request fails).

trackToolCall(params)

Track a tool call event.

trackDecision(params)

Track an agent decision.

completeSession(params)

Complete a session with final metrics.

trackError(params)

Track an error event.

begin(params) / interaction.finish()

Simplified API that auto-manages sessions. Returns an Interaction object.
begin() also accepts name (session title override; auto-named {event}:{id} otherwise) and model. After begin(), interaction.setMetadata(obj) merges keys into the session metadata and interaction.setModel(model) records the session-level model — both are applied on finish() (an explicit finish-time model wins). Client-level equivalents: client.setSessionMetadata(sessionId, obj) / client.setSessionModel(sessionId, model).

interaction.reportDiagnostic(report)

Record an agent’s observation about missing context, a tool problem, a missing capability, or uncertain completion. Call this explicitly while the interaction is active. It does not call a model, change session success, or create a confirmed signal or training label.
Agent reports are available in the published @sentrial/sdk@0.9.0 package. Use a compatible Sentrial collector and trace UI to retain and inspect them; publication alone does not verify delivery from your application.
The client equivalent is await client.reportDiagnostic({ sessionId, report }). Use the same client that created the active session. Both methods resolve to null; resolution is not a durable-delivery receipt. Check transport diagnostics and the retained trace. Finished or degraded interactions do not accept new reports. The SDK sets the report revision and origin; do not supply extra fields. Configured metadata PII redaction, batching, retry and failSilently behavior apply. Each call creates a separate event; recovery does not overwrite the original report or prove business success. The trace UI labels these Agent report and Reported recovered. Older collectors retain generic metadata without the validated report presentation. Absence of a report does not establish success.

LLM Auto-Wrappers

Automatically track all LLM calls with token counts, cost, and latency.
Also available: wrapAnthropic(client), wrapGoogle(model), wrapLLM(client) (auto-detect).

Decorators & Higher-Order Functions

Event Batching

Queue tracking calls and flush them periodically instead of sending each one immediately. Reduces HTTP overhead for high-throughput agents.

PII Redaction

Automatically redact sensitive data before it leaves your infrastructure.
Auto-fetching (pii: true) requires the API key to have the pii-config:read scope. If the key lacks it the fetch is refused and the SDK falls back to the default redaction config (label mode, default fields, builtin patterns) — your org’s configured mode/fields/custom patterns are NOT applied. The SDK logs a one-time warning when this happens.

Cost Calculation

Exported helper functions for calculating LLM API costs. Updated pricing for latest models.
Supported models include GPT-5, GPT-4.1, O-series, Claude Opus/Sonnet 4, Claude 3.5, Gemini 2.5/2.0, and more.

Complete Example

Environment Variables

Transport

The SDK ingests over OTLP (/api/otel/v1/traces) — this is the sole ingestion path. The OTLP path requires the API key to carry both sessions:write and events:write scopes — dashboard-generated keys include both, but a manually-scoped sessions:write-only key will silently drop data. Add events:write to the key.

Next Steps

Python SDK

Python SDK with LangChain support.

Claude Code Integration

Auto-track Claude Agent SDK sessions and tool calls.

Vercel AI SDK

Auto-track generateText, streamText, and tool calls.

OpenAI Agents SDK

Mirror every Agents SDK run into a session — LLM calls, tools, handoffs, guardrails.

Sessions API

REST API reference.