SDK Reference
Sentrial SDK
Official Node.js and Python SDKs for instrumenting your AI agents with one-line tracing.
SDK is available to early access members only.
Install
$npm install @sentrial/sdk
$pip install sentrial
sentrial.init(config)Initialize the Sentrial SDK with your API key and optional configuration.
ParamTypeDescription
apiKeystringYour Sentrial API key (required).environmentstringEnvironment label, e.g. "production" or "staging".agentIdstringA stable identifier for this agent.example
import { Sentrial } from '@sentrial/sdk'
Sentrial.init({
apiKey: process.env.SENTRIAL_API_KEY,
environment: 'production',
agentId: 'research-v2',
})sentrial.session(metadata?)Start a new monitored session. Returns a session handle.
ParamTypeDescription
userIdstringOptional end-user identifier (hashed by default).tagsRecord<string, string>Arbitrary key/value tags for filtering.example
const session = sentrial.session({
userId: 'user_abc123',
tags: { workflow: 'quarterly-report' },
})session.trace(event)Record a trace event — a tool call, LLM call, or custom checkpoint.
ParamTypeDescription
type"tool_call" | "llm_call" | "custom"Event type (required).namestringName of the tool or model called.inputunknownInput payload (automatically scrubbed for PII).outputunknownOutput payload.durationMsnumberWall-clock duration in milliseconds.example
await session.trace({
type: 'llm_call',
name: 'gpt-4o',
input: { messages },
output: { content: response },
durationMs: 312,
})session.end(result?)Close the session and flush all buffered traces to the Sentrial API.
ParamTypeDescription
outcome"success" | "failure" | "partial"Final session outcome.summarystringOptional human-readable session summary.example
await session.end({
outcome: 'success',
summary: 'Generated Q3 earnings report.',
})