Skip to main content
Track AI interactions, monitor performance, and analyze conversations in your Python application with the Agnost AI Conversation SDK.
Agnost receives the input, output, user traits, and metadata you send. For production traffic, use pseudonymous user IDs and redact sensitive data before calling the SDK. See Data Governance.

Installation

Install the SDK using pip or uv:

Quick Start

Initialize the SDK

Import and initialize with your organization ID from the Agnost AI dashboard:
For customization options and advanced configuration, see the Configuration Guide.

Track AI Interactions

Primary Method: begin() and end()

The recommended way to track AI interactions is using begin() to start tracking and end() to complete. begin() Parameters:
All parameters are optional. You can set the input later using set_input() if needed. end(): Success Case: When your AI processing completes successfully, call end() with the output. Latency is automatically calculated:
end(): Error Case: When your AI processing fails, pass success=False and include the error message in the output:

Identify Users

Associate user characteristics for better analytics:
Call identify() once per user to enrich your analytics with user traits like name, email, plan, or any custom attributes. For production traffic, prefer pseudonymous IDs and non-sensitive traits unless your team has approved sending direct identifiers.

Custom Properties

Track additional metadata like model parameters, costs, or custom fields using set_property() or set_properties():

Manual Latency Tracking

By default, latency is automatically calculated from begin() to end(). You can override this if needed:

Cleanup

Ensure all events are sent before your application exits:

Complete Example

Here’s a full example of a chatbot with conversation tracking:

What’s Next?

Need Help?