Skip to main content

Installation

Quick Start

You can also set credentials via environment variables:

@observe Decorator

The @observe decorator is the primary way to instrument your AI calls. It automatically captures inputs, outputs, latency, and exceptions.

Parameters

With All Options

Manual Logging

Use client.observe.log() when you need full control over what gets recorded.

Parameters

Sessions

Group related traces into a session using the agent_session() context manager. This is useful for multi-step agent workflows.

Spans

Break a single trace into sub-steps with the span() context manager.

Span Methods

Scoring

Score traces for evaluation, either manually or with an AI judge.

Prompt Management

Manage versioned prompts and build them with template variables.

Analytics

Access trace analytics and cost data programmatically.

Testing

Create test suites, add cases, and run evaluations against your AI functions.

Versions

Publish, track, and roll back versioned deployments of your AI pipelines.

Error Handling

All SDK errors raise TrainlyError with structured context.