LLM Insights Python client
Ingest and analyze AI-driven insights through our Python client. By integrating with this clien, you can capture LLM responses and user interactions to monitor your application in real-time
Installation
AInsights
A client library to effortlessly integrate powerful insights into your AI flows.
Create a client with minimal configuration and capture and request/response pair for future analysis.
Notes
Thread-safety
The insights client is thread-safe. You can safely use a single client from multiple threads.
Asynchronous
The insights client is asynchronous. capture()
-ing requests/responses is a non-blocking operation, and it will not interrupt the flow of your application.
Getting Started
1. Register on the Platform
Visit the platform and register for an account.
After registration, create an organization in the dashboard.
2. Create an API Key
Navigate to the Insights API page in your account.
Generate an API key. This API key will be used to authenticate your requests.
Note: The same API key can be used for both Client Insights and Voice Insights. The only difference is the ingestion endpoint.
Usage pattern #1: Create client instance
If you prefer creating and using client instance, just add an AInsights
instance next to your OpenAI
one, and capture every interaction by adding a single call.
It doesn't matter if you're using simple free-text outputs, JSON outputs or tools, the insights client will capture everything.
Check out this working sample
Usage pattern #2: Use a global instance
You like it simple. You just want to call OpenAI from anywhere in your code, and the insights should be no different.
Just create a simple file (ainsights_instance.py
is a reasonable name) in your project, and import it everywhere. The client is thread-safe.
Check out this working sample
Then, calling OpenAI and capturing is as easy as:
It doesn't matter if you're using simple free-text outputs, JSON outputs or tools, the insights client will capture everything.
User tracking
If you want your insights to be tied to a specific user, you can specify the user_id
argument when calling capture(...)
.
See "Usage pattern #1" above for specific details.
Sample applications
Check out the samples directory for working examples you can try out in no time.
Last updated
Was this helpful?