Installation
Quick Start
Module Functions
sentrial.configure()
Configure the default Sentrial client.
sentrial.begin()
Begin tracking an interaction. Returns an Interaction object.
External user ID.
Event type / agent name.
Input data.
Custom event ID (auto-generated if omitted).
Conversation ID for grouping.
Additional metadata.
Interaction Class
Returned bysentrial.begin(). Provides methods to track events and finish the interaction.
interaction.finish()
Finish the interaction and record final metrics.
interaction.track_tool_call()
Track a tool call within the interaction.
interaction.track_decision()
Track an agent decision.
SentrialClient Class
For full control over session management.Constructor
client.create_session()
Create a new tracking session. Returns the session ID.
client.track_tool_call()
client.track_decision()
client.complete_session()
Complete a session with final metrics.
client.track_error()
LLM Auto-Wrappers
Automatically track all LLM calls with token counts, cost, and latency.wrap_anthropic(client), wrap_google(model), wrap_llm(client) (auto-detect).
Decorators
Context Manager
Event Batching
Queue tracking calls and flush periodically to reduce HTTP overhead.PII Redaction
Automatically redact sensitive data before it leaves your infrastructure.Cost Calculation Helpers
Static methods to calculate LLM API costs.calculate_openai_cost()
calculate_anthropic_cost()
calculate_google_cost()
Async Support
All SDK classes have async equivalents for use withasyncio.
client.flush()
Flush any queued events immediately. No-op if batching is not enabled.
client.shutdown()
Shut down the event batcher, flushing remaining events. Call this before your process exits to ensure all events are sent.
LangChain Integration
Use
SentrialCallbackHandler to automatically track all LLM calls, tool usage, and agent decisions in LangChain.
Full LangChain Integration Guide →Next Steps
LangChain Integration
Automatic tracking for LangChain agents.
Claude Code Integration
Auto-track Claude Agent SDK sessions and tool calls.
Mastra Integration
One-line setup for Mastra AI agents.
Sessions API
REST API reference.

