Skip to main content

Client for Spryngtime Usage Analytics & Billing API

Project description

spryngtime-analytics-sdk

Spryngtime Usage Analytics & Billing API

PyPI README.md

Table of Contents

Requirements

Python >=3.7

Installing

pip install spryngtime-analytics-sdk==1.1.5

Getting Started

from pprint import pprint
from spryngtime_analytics_sdk import SpryngtimeAnalyticsSdk, ApiException

spryngtimeanalyticssdk = SpryngtimeAnalyticsSdk(
    api_key="YOUR_API_KEY",
)

try:
    # Track usage data
    spryngtimeanalyticssdk.usage_tracking.track_usage(
        user="string_example",
        query="string_example",
        conversation_id="string_example",
        latency=1,
        open_ai_response={
            "id": "id_example",
            "object": "object_example",
            "created": 1,
            "model": "model_example",
            "choices": [
                {
                    "index": 1,
                    "message": {
                        "role": "role_example",
                        "content": "content_example",
                    },
                    "finish_reason": "finish_reason_example",
                }
            ],
            "usage": {
                "prompt_tokens": 1,
                "completion_tokens": 1,
                "total_tokens": 1,
            },
        },
        usage={
            "prompt_tokens": 1,
            "completion_tokens": 1,
            "total_tokens": 1,
        },
    )
except ApiException as e:
    print("Exception when calling UsageTrackingApi.track_usage: %s\n" % e)
    pprint(e.body)
    pprint(e.headers)
    pprint(e.status)
    pprint(e.reason)
    pprint(e.round_trip_time)

Async

async support is available by prepending a to any method.

import asyncio
from pprint import pprint
from spryngtime_analytics_sdk import SpryngtimeAnalyticsSdk, ApiException

spryngtimeanalyticssdk = SpryngtimeAnalyticsSdk(
    api_key="YOUR_API_KEY",
)


async def main():
    try:
        # Track usage data
        await spryngtimeanalyticssdk.usage_tracking.atrack_usage(
            user="string_example",
            query="string_example",
            conversation_id="string_example",
            latency=1,
            open_ai_response={
                "id": "id_example",
                "object": "object_example",
                "created": 1,
                "model": "model_example",
                "choices": [
                    {
                        "index": 1,
                        "message": {
                            "role": "role_example",
                            "content": "content_example",
                        },
                        "finish_reason": "finish_reason_example",
                    }
                ],
                "usage": {
                    "prompt_tokens": 1,
                    "completion_tokens": 1,
                    "total_tokens": 1,
                },
            },
            usage={
                "prompt_tokens": 1,
                "completion_tokens": 1,
                "total_tokens": 1,
            },
        )
    except ApiException as e:
        print("Exception when calling UsageTrackingApi.track_usage: %s\n" % e)
        pprint(e.body)
        pprint(e.headers)
        pprint(e.status)
        pprint(e.reason)
        pprint(e.round_trip_time)


asyncio.run(main())

Raw HTTP Response

To access raw HTTP response values, use the .raw namespace.

from pprint import pprint
from spryngtime_analytics_sdk import SpryngtimeAnalyticsSdk, ApiException

spryngtimeanalyticssdk = SpryngtimeAnalyticsSdk(
    api_key="YOUR_API_KEY",
)

try:
    # Track usage data
    track_usage_response = spryngtimeanalyticssdk.usage_tracking.raw.track_usage(
        user="string_example",
        query="string_example",
        conversation_id="string_example",
        latency=1,
        open_ai_response={
            "id": "id_example",
            "object": "object_example",
            "created": 1,
            "model": "model_example",
            "choices": [
                {
                    "index": 1,
                    "message": {
                        "role": "role_example",
                        "content": "content_example",
                    },
                    "finish_reason": "finish_reason_example",
                }
            ],
            "usage": {
                "prompt_tokens": 1,
                "completion_tokens": 1,
                "total_tokens": 1,
            },
        },
        usage={
            "prompt_tokens": 1,
            "completion_tokens": 1,
            "total_tokens": 1,
        },
    )
    pprint(track_usage_response.headers)
    pprint(track_usage_response.status)
    pprint(track_usage_response.round_trip_time)
except ApiException as e:
    print("Exception when calling UsageTrackingApi.track_usage: %s\n" % e)
    pprint(e.body)
    pprint(e.headers)
    pprint(e.status)
    pprint(e.reason)
    pprint(e.round_trip_time)

Reference

spryngtimeanalyticssdk.usage_tracking.track_usage

Track usage data

🛠️ Usage

spryngtimeanalyticssdk.usage_tracking.track_usage(
    user="string_example",
    query="string_example",
    conversation_id="string_example",
    latency=1,
    open_ai_response={
        "id": "id_example",
        "object": "object_example",
        "created": 1,
        "model": "model_example",
        "choices": [
            {
                "index": 1,
                "message": {
                    "role": "role_example",
                    "content": "content_example",
                },
                "finish_reason": "finish_reason_example",
            }
        ],
        "usage": {
            "prompt_tokens": 1,
            "completion_tokens": 1,
            "total_tokens": 1,
        },
    },
    usage={
        "prompt_tokens": 1,
        "completion_tokens": 1,
        "total_tokens": 1,
    },
)

⚙️ Parameters

user: str
query: str
conversation_id: str
latency: int
open_ai_response: OpenAiResponse
usage: UsageDetail

⚙️ Request Body

TrackUsageRequest

🌐 Endpoint

/trackUsage post

🔙 Back to Table of Contents


spryngtimeanalyticssdk.default.root_get

Home

🛠️ Usage

spryngtimeanalyticssdk.default.root_get()

🌐 Endpoint

/ get

🔙 Back to Table of Contents


spryngtimeanalyticssdk.default.users_post

Adds a new user

🛠️ Usage

spryngtimeanalyticssdk.default.users_post(
    id=10,
    name="Jessica Smith",
)

⚙️ Parameters

id: int
name: str

⚙️ Request Body

Any

🌐 Endpoint

/users post

🔙 Back to Table of Contents


Author

This Python package is automatically generated by Konfig

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

spryngtime_analytics_sdk-1.1.5.tar.gz (56.3 kB view hashes)

Uploaded Source

Built Distribution

spryngtime_analytics_sdk-1.1.5-py3-none-any.whl (91.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page