Metadata-Version: 2.4
Name: litellm-retry-wrapper
Version: 0.1.0
Summary: A robust wrapper for LiteLLM with retry logic and rate limiting
Project-URL: Homepage, https://github.com/stylumia/litellm-retry-wrapper
Project-URL: Repository, https://github.com/stylumia/litellm-retry-wrapper
Author-email: Stylumia <tech@stylumia.com>
License: MIT License
        
        Copyright (c) 2025 LiteLLM Retry Wrapper Contributors
        
        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. 
License-File: LICENSE
Keywords: litellm,llm,rate-limiting,retry
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Python: >=3.8
Requires-Dist: litellm>=1.0.0
Requires-Dist: ratelimit>=2.2.1
Requires-Dist: tenacity>=8.0.0
Description-Content-Type: text/markdown

# LiteLLM Retry Wrapper

A robust Python wrapper for LiteLLM that provides retry mechanisms, rate limiting, and error handling for LLM API calls.

## Features

- 🔄 Automatic retry mechanism with exponential backoff
- ⏱️ Built-in rate limiting
- 🎯 Configurable parameters for retries and rate limits
- 📝 Comprehensive logging
- 🛡️ Error handling and exception management
- 🔧 Easy to customize and extend

## Installation

```bash
uv pip install litellm-retry-wrapper
```

## Quick Start

```python
from call_litellm_with_retry import LiteLLMCaller

# Initialize the caller
llm_caller = LiteLLMCaller(
    model_name="gemini/gemini-2.0-flash",
    rpm=2000,
    max_retries=3
)

# Prepare your messages
messages = [
    {
        "role": "user",
        "content": "Write a short poem about artificial intelligence."
    }
]

# Make the API call
response = llm_caller.complete(
    messages=messages,
    temperature=0.7,
    max_tokens=100
)

print(response.choices[0].message.content)
```

## Configuration

The `LiteLLMCaller` class accepts the following parameters:

- `model_name`: The name of the LLM model to use (default: "gemini/gemini-2.0-flash")
- `rpm`: Rate limit in requests per minute (default: 2000)
- `max_retries`: Maximum number of retry attempts (default: 3)
- `min_retry_wait`: Minimum wait time between retries in seconds (default: 4)
- `max_retry_wait`: Maximum wait time between retries in seconds (default: 10)

## Environment Variables

Create a `.env` file with your API keys:

```env
GEMINI_API_KEY=your_api_key_here
```

## Development

To set up the development environment:

```bash
# Clone the repository
git clone https://github.com/sanjeed5/litellm-retry-wrapper.git
cd litellm-retry-wrapper

# Install dependencies
uv venv
source .venv/bin/activate
uv sync
```

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

## Acknowledgments

- Built with [LiteLLM](https://github.com/BerriAI/litellm)
- Uses [tenacity](https://github.com/jd/tenacity) for retry logic
- Uses [ratelimit](https://github.com/tomasbasham/ratelimit) for rate limiting
