Skip to main content

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.6

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,
        custom_properties={},
        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,
            custom_properties={},
            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,
        custom_properties={},
        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,
    custom_properties={},
    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
custom_properties: TrackUsageRequestCustomProperties
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

Release files for spryngtime-analytics-sdk 1.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for spryngtime-analytics-sdk 1.1.6
File Size Uploaded
spryngtime_analytics_sdk-1.1.6.tar.gz 95.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for spryngtime-analytics-sdk 1.1.6
File Interpreter ABI Platform
spryngtime_analytics_sdk-1.1.6-py3-none-any.whl Python 3 none any Details

Total release size: 189.8 kB

Release files / spryngtime_analytics_sdk-1.1.6.tar.gz

Download URL spryngtime_analytics_sdk-1.1.6.tar.gz
Size 95.1 kB
Tags Source
SHA-256 checksum
How to use checksums
1b3ab4bb11b593f4fc8c0b3ad0009ed07efaa0c091c85b447003ef1bac4b0cbc
BLAKE2b-256 checksum
How to use checksums
5eab5e3110f5c4eec7f64fd2a0413977d4d3ebba2173178b683e51207dd66839
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release files / spryngtime_analytics_sdk-1.1.6-py3-none-any.whl

Download URL spryngtime_analytics_sdk-1.1.6-py3-none-any.whl
Size 94.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
2c5747d8556a06874f1f4f5317b59a10b7368cd86b7f2d834159a7f82e5dc6e1
BLAKE2b-256 checksum
How to use checksums
96192837183796176a8e52ea093356e8793ab23d9aa90752c96cd0141308275b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.11.7

Release history Release notifications | RSS feed

This release

1.1.6 This release

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page