Tracking usage based on results

You may sometimes want to bill and track based on results instead of pure usage.

For example, if you're builing an AI customer support bot that bills based off of "questions resolved and answered", you may not bill for all usage.

In that case, you can use customProperties in the trackUsage API to track each request that should or should not be billed based on a result by adding an outcome field.

Then, in our dashboard, you can filter by this specific custom property. Also, you'll be able to export with the getUsage API

Here's a code example with our Javascript/Typescript SDK:

const trackUsageResponse = await spryngtimeanalyticssdk.usageTracking.trackUsage({
    key: "companytest1",
    query: query,
    openAiResponse: chatCompletion,
    customProperties:{conversationId: "customer3", outcome:"bill"},
    tags: ["support"],

Last updated