Metadata-Version: 2.4
Name: llm-limiters
Version: 0.1.2
Summary: A thread-safe and async rate limiter for Gemini and OpenAI models.
Author-email: Nagomi Jayamani <nagomijayamani@gmail.com>
License: MIT License
        
        Copyright (c) 2025 Nagomi Jayamani
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
Project-URL: Homepage, https://github.com/Jayam-Nagomi/llm-limiters
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file


# LLM Limiters

A lightweight, thread-safe, and async Python library to manage rate limits (RPM, TPM, RPD) for LLMs like Google Gemini and OpenAI.

## Installation

```bash
pip install llm-limiters
```

## Usage

### Standard Rate Limiter (Decorators)

```python
from llm_limiters import RateLimiter

limiter = RateLimiter(tier="free")

@limiter.limit(model_priority=["gemini-2.0-flash", "gpt-4o-mini"])
def call_llm(prompt, model_name=None):
    # Your API call here
    return response
```

### Live/WebSocket Limiter

```python
import asyncio
from llm_limiters import LiveRateLimiter

async def main():
    limiter = LiveRateLimiter(tier="tier1")
    
    allowed, reason = await limiter.check_availability("gemini-2.0-flash-live-001")
    if allowed:
        await limiter.acquire_session("gemini-2.0-flash-live-001")
        # Start websocket...
```
