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

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.1.tar.gz.

File metadata

File hashes

Hashes for spryngtime_analytics_sdk_python_sdk-1.0.1.tar.gz
Algorithm Hash digest
SHA256 e716dfe22129e72942dce70eade8d1d0093683d0876e45c79ef3ba4c2f77638b
MD5 e0c81e88eb4c442ee6e4f9699bc4d757
BLAKE2b-256 2eeca33369f4b827684d1b39ee2347741bdab256c5c6c5a48d11799d4a3efdc0

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for spryngtime_analytics_sdk_python_sdk-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ba3884ee9113ace18b52f7ece0c2d3019a53e5b295cb474e3215ea99f94b6a39
MD5 0b41f11638ccf3d144b08370d6e2a9fb
BLAKE2b-256 02e582a12e52e7db198a29af4cc66ec1ae4aaa45f820467cbab5cd7317e3e3cb

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