Client for Spryngtime Usage Analytics & Billing API
Project description
spryngtime-analytics-sdk-python-sdk
Spryngtime Usage Analytics & Billing API
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
🌐 Endpoint
/trackUsage
post
spryngtimeanalyticssdk.default.root_get
Home
🛠️ Usage
spryngtimeanalyticssdk.default.root_get()
🌐 Endpoint
/
get
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
🌐 Endpoint
/users
post
Author
This Python package is automatically generated by Konfig
Project details
Release history Release notifications | RSS feed
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
- Download URL: spryngtime_analytics_sdk_python_sdk-1.0.0.tar.gz
- Upload date:
- Size: 55.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51205bb67c6c03ae8467d0aec0f146905fd62d7dba53225153f6c8656df3a04f |
|
MD5 | 397f4efcf3adacf5da5285db0d196fe1 |
|
BLAKE2b-256 | f20714363d10a0c00e8fbb60c815fe334edafd5ab80e271858a1c307d1ad1413 |
File details
Details for the file spryngtime_analytics_sdk_python_sdk-1.0.0-py3-none-any.whl
.
File metadata
- Download URL: spryngtime_analytics_sdk_python_sdk-1.0.0-py3-none-any.whl
- Upload date:
- Size: 90.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.11.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 28d55b758621e8257f75452993526c0c5882b50e98545206de96358610f2933b |
|
MD5 | 694033d85bcc3d588a538dbc687afb8f |
|
BLAKE2b-256 | 666621f86182c4e20f3bdd0b04affc0fbc484d487a07d7cbf7c808f472777706 |