Skip to main content

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

  1. Install build tools:

    pip install build twine
    
  2. Build the package:

    python -m build
    
  3. Test the build locally:

    pip install dist/tailli-0.1.0.tar.gz
    
  4. 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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tailli-0.1.0.tar.gz (6.6 kB view details)

Uploaded Source

Built Distribution

tailli-0.1.0-py3-none-any.whl (7.2 kB view details)

Uploaded Python 3

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

Hashes for tailli-0.1.0.tar.gz
Algorithm Hash digest
SHA256 37f007323ea3d388d25ea8120d56bc67fee76daa570457a66105b4f3856b49b0
MD5 2c8148a9dfcf8443a1cc9774fa49df90
BLAKE2b-256 419aa9c6a4f0b99cea8af6925955d47805856ee2e8fed1044f39e20ddbb9f451

See more details on using hashes here.

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

Hashes for tailli-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 394d57817e3db3415ca0e8ba8ece5f0cab91f3b59ead3aad8a981724b1dd6cde
MD5 1c546f91f57a0690df4b408723d1ba04
BLAKE2b-256 f0bb6d4dbcfa819bf54c924cdb7ac70d28792f128b13f8fecce2bddc76c03d5d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page