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.2
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.2.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | cd0b7787b99094dae20ff647d75dcf4f6d242454b6ebc6c912a28e419953e7b0 |
|
MD5 | 37847dd9af094ac9c0754f926cbd1f87 |
|
BLAKE2b-256 | 22aab901a758626e5ef7ef6299ad33d92fd135ecc2c8f9f5808dbdf898cc0368 |
Close
Hashes for spryngtime_analytics_sdk-1.1.2-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 51d5aafa211c87f9218754f0ad83d16ff5c9a38c056e4d270927e196a7b238e7 |
|
MD5 | 51f25bd6cc437e884e212bf23b66f260 |
|
BLAKE2b-256 | 875b6d121e4fc26f7817f2587b6734ee16f947ceb683c1ae6329f9e08230b4f8 |