Skip to content

Quickstart

Once you have reviewed which events to track, you can use one of our SDK's in your application to start tracking events.

Install SDK

Firstly you need to install one of our SDK's (Python, Node.js, Javascript Web) in your application:

npm i @trubrics/trubrics
pip install trubrics-beta

Initialise SDK and authenticate with Trubrics

Now ensure that Trubrics is imported & initialised in your app:

import { Trubrics } from "@trubrics/trubrics";

export const trubrics = new Trubrics({ apiKey: TRUBRICS_API_KEY });
from trubrics_beta import Trubrics

trubrics = Trubrics(api_key="TRUBRICS_API_KEY")

Project API key

Your trubrics API key is unique to your project. Login to Trubrics, and copy your project API key from the settings page. This is a write only API key that allows you to push events.

Track user events (Sign Up, Conversion, etc.)

trubrics.track({
    event: "Sign Up",
    userId: "user_id",
    properties: {
        country: "USA",
        company: "Acme",  // Add more properties as needed
    },
});
trubrics.track(
    event="Sign Up",
    user_id="user_id",
    properties={
        "country": "USA",
        "company": "Acme",  # Add more properties as needed
    },
)

For more information on SDK's and how to track events, please refer to the SDK documentation.

Track AI events (Prompts, Generations, etc.)

If you are using Open AI, you can easily start tracking prompts, generations and tool calls:

In order to automatically detect LLM calls, your LLM SDK must be fed into the Trubrics constructor:

import { Trubrics } from "@trubrics/trubrics";
import { OpenAI } from 'openai';

export const trubrics = new Trubrics({ 
    apiKey: TRUBRICS_API_KEY,
    openAI: OpenAI
});
from trubrics_beta import Trubrics

trubrics = Trubrics(api_key="TRUBRICS_API_KEY")

Project API key

Your trubrics API key is unique to your project. Login to Trubrics, and copy your project API key from the settings page. This is a write only API key that allows you to push events.

Now start tacking prompts, generations and tool calls from OpenAI by using the withProperties wrapper:

The withProperties function wraps around your LLM function and returns the same response object as your LLM function. It takes an additional properties dictionary, which allows you to add context to your LLM events such as user ID's and thread ID's.


# Coming soon