Python client for Tailli API key management and usage tracking
Project description
Tailli API Client
A high-performance Python client for Tailli API key management and usage tracking. This client provides easy-to-use async interfaces with built-in caching and background usage recording for optimal performance - track consumption accurately without adding latency to your APIs.
Features
- 🚀 Asynchronous API with proper connection management
- 💾 Local caching of API key validation
- 🔄 Background usage recording with automatic retries
- ⚡ Low-latency operations prioritizing your application's performance
- 🛡️ Type-safe with full typing support
Installation
pip install tailli
Quick Start
from tailli import TailliClient
async def main():
async with TailliClient() as client:
# Validate an API key and use it in a session
api_key = "your-api-key"
try:
async with client.validated_session(api_key):
# Your API calls here
await client.record_usage(api_key, 5)
except InvalidApiKeyError:
print("Invalid API key")
if __name__ == "__main__":
asyncio.run(main())
For more examples, check out the examples directory.
Building and Publishing
-
Install build tools:
pip install build twine
-
Build the package:
python -m build
-
Test the build locally:
pip install dist/tailli-0.1.0.tar.gz
-
Upload to PyPI:
python -m twine upload dist/*
Project Structure
tailli/
├── pyproject.toml # Project configuration and dependencies
├── setup.cfg # Additional build configuration
├── README.md # This file
├── LICENSE # MIT License
├── requirements.txt # Python dependencies
├── src/
│ └── tailli/ # Main package code
│ ├── __init__.py
│ ├── client.py # Core client implementation
│ ├── models.py # Pydantic models
│ └── utils.py # Utility functions
├── tests/ # Test suite
└── examples/ # Example code
Sample Implementation
The reference implementation can be found in the examples directory. This shows the recommended way to use the client, including:
- API key validation
- Usage recording
- Error handling
- Async context management
License
The Tailli Client (but not the Tailli backend) is licensed under the MIT License - see the LICENSE file for details.
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 tailli-0.2.0.tar.gz
.
File metadata
- Download URL: tailli-0.2.0.tar.gz
- Upload date:
- Size: 6.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de0a0a964f340de543ce0cf330a7a3a84e39a7a58f01e2653624be97fd567010 |
|
MD5 | 413fe73915bfb2dfef9f1da31940ef90 |
|
BLAKE2b-256 | a5cb36bd540ea7ae8751b513bb1f68b721e8b04053e796fbe68bbf0aa8a042c3 |
File details
Details for the file tailli-0.2.0-py3-none-any.whl
.
File metadata
- Download URL: tailli-0.2.0-py3-none-any.whl
- Upload date:
- Size: 7.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 7034ae9a5013154f1fc83340e55b98184dda5ced340bd944b08cb80f9f263c81 |
|
MD5 | 6a4f135f117627dbd55904729c1db753 |
|
BLAKE2b-256 | d1ece5602bd8265ae4a81626e2c5819694d664ec277338fbcf9ba66b2057c3ec |