Client for Spryngtime Usage Analytics & Billing API
Project description
spryngtime-analytics-sdk
Spryngtime Usage Analytics & Billing API
Table of Contents
Requirements
Python >=3.7
Installing
pip install spryngtime-analytics-sdk==1.1.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",
conversation_id="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",
conversation_id="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",
conversation_id="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",
conversation_id="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
conversation_id: 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
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
Close
Hashes for spryngtime_analytics_sdk-1.1.1.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 75ef47deeae16047fd3b83108a1e97313c029e2aee4bb303647cf2101021ec99 |
|
MD5 | 3aa390578c5c6cca865b8508e3b852de |
|
BLAKE2b-256 | ee2df69b758d3da3ba2702f9d0ec2b8a49767a8802bf8f4ed1700bb49265f49a |
Close
Hashes for spryngtime_analytics_sdk-1.1.1-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 142996616723770a06232f39d881cb26850123bfdad76bc55a71c667b686783d |
|
MD5 | 82d75cf6f5074cffc4dadb7828d036aa |
|
BLAKE2b-256 | 58fa2e1c20eef4bc0f92bd33b6151d806ba635efcdb4ed09033310b8e8aa2bab |