Metadata-Version: 2.1
Name: tokenator
Version: 0.1.4
Summary: Token usage tracking wrapper for LLMs
License: MIT
Author: Ujjwal Maheshwari
Author-email: your.email@example.com
Requires-Python: >=3.9,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Requires-Dist: alembic (>=1.13.0,<2.0.0)
Requires-Dist: anthropic (>=0.40.0,<0.41.0)
Requires-Dist: openai (>=1.57.0,<2.0.0)
Requires-Dist: requests (>=2.32.3,<3.0.0)
Requires-Dist: sqlalchemy (>=2.0.0,<3.0.0)
Description-Content-Type: text/markdown

# Tokenator : Easiest way to track and analyze LLM token usage and cost

Have you ever wondered about :
- How many tokens does your AI agent consume? 
- How much does it cost to do run a complex AI workflow with multiple LLM providers?
- How much money did I spent today on development?

Afraid not, tokenator is here! With tokenator's easy to use API, you can start tracking LLM usage in a matter of minutes and track your LLM usage.

Get started with just 3 lines of code!

## Installation

```bash
pip install tokenator
```

## Usage

### OpenAI

```python
from openai import OpenAI
from tokenator import tokenator_openai

openai_client = OpenAI(api_key="your-api-key")

# Wrap it with Tokenator
client = tokenator_openai(openai_client)

# Use it exactly like the OpenAI client
response = client.chat.completions.create(
    model="gpt-4o",
    messages=[{"role": "user", "content": "Hello!"}]
)
```

### Cost Analysis

```python
from tokenator import cost

# Get usage for different time periods
cost.last_hour()
cost.last_day()
cost.last_week()
cost.last_month()

# Custom date range
cost.between("2024-03-01", "2024-03-15")

# Get usage for different LLM providers
cost.last_day("openai")
cost.last_day("anthropic")
cost.last_day("google")
```

### Example `cost` object

```json

```

## Features

- Drop-in replacement for OpenAI, Anthropic client
- Automatic token usage tracking
- Cost analysis for different time periods
- SQLite storage with zero configuration
- Thread-safe operations
- Minimal memory footprint
- Minimal latency footprint

Most importantly, none of your data is ever sent to any server.

## License

MIT 
