Skip to content

API reference

To get started collecting events in your application using Trubrics, consult first our SDKs. If your language is not supported, you can send events directly to our API:

curl -X 'POST' \
  'https://api.trubrics.com/publish_event?project_api_key=TRUBRICS_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "user_id": "user_id",
  "event": "LLM generation",
  "timestamp": "2024-10-09T13:21:46.182Z",
  "properties": {
    "$text": "Tell me a joke",
    "$thread_id": "thread_id",
    "$assistant_id": "assistant_id",
    "a_custom_property": "any custom value"
  }
}'

The request body should contain the following parameters:

Parameter Type Description Required
user_id str The distinct ID of the signed in user. yes
event str The name of the event you are tracking. This can range from "User prompt", "Sign in", "Generation", etc. yes
timestamp str The timestamp of the event. yes
properties dict[str,any] A list of properties of the event. For example, a "Generation" event could have properties "Cost of generation" or "Prompt template". Trubrics properties are prefixed with a $. no

Authentication

This API contains public endpoints only, that will allow your to write to your Trubrics project. The project_api_key is a required path parameter to your request.

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.

Trubrics properties

Any property that begins with a $ is a property recognised by Trubrics. This allows us to perform certain actions in the ingestion pipeline and backend. Here are a list of Trubrics properties:

  • $text: events that contain a textual element should use this property, as it allows Trubrics to tag the event with text attributes during ingestion. Text attributes can be managed directly in Trubrics.

  • $thread_id: to identify when a user is interacting with an AI assistant within their session. This allows you to distinguish between non-AI assistant interactions such as "Sign In" and events within a thread such as "Prompt" and "Generation". With an LLM powered assistant, this ID should be unique for each different conversation.

  • $assistant_id: events that are made by an assistant, such as "Generation" or "Query database", should use this property. Typically for LLM assistants this can be set to the model name, such as "GPT-4" or "GPT-3.5-turbo".

  • $prompt_id: Identifies as specific prompt, or user message. This is useful when that prompt needs to be tagged with an attribute later on.

  • $generation_id: Identifies as specific generation, or assistant message. This is useful when that generation needs to be tagged with an attribute later on.