Manually track analytics

So you're ready to start tracking analytics & usage for your AI product!

This quickstart is if you do NOT want to use the OpenAI wrapper SDKs. For example, if you are using another LLM provider (like Anthropic) or are using a custom implementation OpenAI SDK implementation (like our OpenAI load balancer)

Get API key

Sign up for an account and get your API key at https://accounts.usespryngtime.com/sign-in

Install package

If Python, install our Python package

pip install spryngtime_analytics_sdk_python_sdk

If Node.js, install our Node.js package

npm i test_spryngtime_sdk

Track with one line of code!

Track token usage with a simple line of code

Javascript:

const {SpryngtimeAnalyticsSdk} = require("test_spryngtime_sdk");

const spryngtimeanalyticssdk = new SpryngtimeAnalyticsSdk({
    apiKey: "apiKey123",
});

const chatCompletion = await openai.chat.completions.create({
    messages: [{ role: 'user', content: 'what is 2+45' }],
    model: 'gpt-3.5-turbo',
});

// Replace `key` with the customer/company that you want to associate the usage with
// For example, if the chatCompletion is for `companyA`, then I'll track the usage against `companyA`
const trackUsageResponse =
    await spryngtimeanalyticssdk.usageTracking.trackUsage({
        key: "companyA",
        openAIResponse:chatCompletion,
    });

Python code:

from spryngtime_analytics_sdk import SpryngtimeAnalyticsSdk

spryngtimeanalyticssdk = SpryngtimeAnalyticsSdk(
    api_key="apiKey123",
)

openAICompletion = client.chat.completions.create(
  model="gpt-3.5-turbo",
  messages=[[{ role: 'user', content: 'what is 2+45' }]]
)

spryngtimeanalyticssdk.usage_tracking.track_usage(
        key="string_example",
        open_ai_response=openAICompletion
)

Last updated