Skip to main content

Client for Spryngtime Usage Analytics & Billing API

Project description

spryngtime-analytics-sdk-python-sdk

Spryngtime Usage Analytics & Billing API

PyPI README.md

Table of Contents

Requirements

Python >=3.7

Installing

pip install spryngtime-analytics-sdk-python-sdk==1.0.0

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(
        key="string_example",
        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(
            key="string_example",
            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(
        key="string_example",
        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(
    key="string_example",
    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

key: str
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

Built Distribution

File details

Details for the file spryngtime_analytics_sdk_python_sdk-1.0.0.tar.gz.

File metadata

File hashes

Hashes for spryngtime_analytics_sdk_python_sdk-1.0.0.tar.gz
Algorithm Hash digest
SHA256 51205bb67c6c03ae8467d0aec0f146905fd62d7dba53225153f6c8656df3a04f
MD5 397f4efcf3adacf5da5285db0d196fe1
BLAKE2b-256 f20714363d10a0c00e8fbb60c815fe334edafd5ab80e271858a1c307d1ad1413

See more details on using hashes here.

File details

Details for the file spryngtime_analytics_sdk_python_sdk-1.0.0-py3-none-any.whl.

File metadata

File hashes

Hashes for spryngtime_analytics_sdk_python_sdk-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 28d55b758621e8257f75452993526c0c5882b50e98545206de96358610f2933b
MD5 694033d85bcc3d588a538dbc687afb8f
BLAKE2b-256 666621f86182c4e20f3bdd0b04affc0fbc484d487a07d7cbf7c808f472777706

See more details on using hashes here.

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