Python SDK
The official Alephant Analytics Python SDK provides convenient access to the Alephant Analytics API from Python scripts or data science notebooks. It supports both synchronous and asynchronous execution, enabling high-performance queries for dashboards, AI cost optimization, and alerting engines.
Installation
Install the SDK via pip:
Initialization
You can initialize either a synchronous or asynchronous client depending on your architecture.
Synchronous Client
Asynchronous Client
Ideal for FastAPI, async web frameworks, or highly concurrent applications:
Example Usage
Live 24-Hour Panel Overview
Retrieve a rolling live-24h dashboard style panel of top models and keys.
Retrieving Department Overrides and Analytics
Fetch cost breakdowns for a specific department.
Error Handling
Any request that results in a 4xx or 5xx status code will raise an exception corresponding to the type of error (ApiError, RateLimitError, etc.). Catch these natively in Python to perform fallback logic or exponential backoffs.