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

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.6.tar.gz (95.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

spryngtime_analytics_sdk-1.1.6-py3-none-any.whl (94.7 kB view details)

Uploaded Python 3

File details

Details for the file spryngtime_analytics_sdk-1.1.6.tar.gz.

File metadata

  • Download URL: spryngtime_analytics_sdk-1.1.6.tar.gz
  • Upload date:
  • Size: 95.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.7

File hashes

Hashes for spryngtime_analytics_sdk-1.1.6.tar.gz
Algorithm Hash digest
SHA256 1b3ab4bb11b593f4fc8c0b3ad0009ed07efaa0c091c85b447003ef1bac4b0cbc
MD5 e368165e29ceb8fc94f5f0c29817143d
BLAKE2b-256 5eab5e3110f5c4eec7f64fd2a0413977d4d3ebba2173178b683e51207dd66839

See more details on using hashes here.

File details

Details for the file spryngtime_analytics_sdk-1.1.6-py3-none-any.whl.

File metadata

File hashes

Hashes for spryngtime_analytics_sdk-1.1.6-py3-none-any.whl
Algorithm Hash digest
SHA256 2c5747d8556a06874f1f4f5317b59a10b7368cd86b7f2d834159a7f82e5dc6e1
MD5 87991387e4e3b29198b436867f0181e5
BLAKE2b-256 96192837183796176a8e52ea093356e8793ab23d9aa90752c96cd0141308275b

See more details on using hashes here.

Supported by

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