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
Contributing
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
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.1.0.tar.gz
.
File metadata
- Download URL: tailli-0.1.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.1.1 CPython/3.11.10
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 37f007323ea3d388d25ea8120d56bc67fee76daa570457a66105b4f3856b49b0 |
|
MD5 | 2c8148a9dfcf8443a1cc9774fa49df90 |
|
BLAKE2b-256 | 419aa9c6a4f0b99cea8af6925955d47805856ee2e8fed1044f39e20ddbb9f451 |
File details
Details for the file tailli-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: tailli-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.2 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 | 394d57817e3db3415ca0e8ba8ece5f0cab91f3b59ead3aad8a981724b1dd6cde |
|
MD5 | 1c546f91f57a0690df4b408723d1ba04 |
|
BLAKE2b-256 | f0bb6d4dbcfa819bf54c924cdb7ac70d28792f128b13f8fecce2bddc76c03d5d |