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.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
🌐 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.1.tar.gz
.
File metadata
- Download URL: spryngtime_analytics_sdk_python_sdk-1.0.1.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 | e716dfe22129e72942dce70eade8d1d0093683d0876e45c79ef3ba4c2f77638b |
|
MD5 | e0c81e88eb4c442ee6e4f9699bc4d757 |
|
BLAKE2b-256 | 2eeca33369f4b827684d1b39ee2347741bdab256c5c6c5a48d11799d4a3efdc0 |
File details
Details for the file spryngtime_analytics_sdk_python_sdk-1.0.1-py3-none-any.whl
.
File metadata
- Download URL: spryngtime_analytics_sdk_python_sdk-1.0.1-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 | ba3884ee9113ace18b52f7ece0c2d3019a53e5b295cb474e3215ea99f94b6a39 |
|
MD5 | 0b41f11638ccf3d144b08370d6e2a9fb |
|
BLAKE2b-256 | 02e582a12e52e7db198a29af4cc66ec1ae4aaa45f820467cbab5cd7317e3e3cb |