Metadata-Version: 2.4
Name: tokenwise-py
Version: 0.1.0
Summary: Estimate tokens and cost of a prompt across popular LLMs.
Author: episodely
License: MIT
Project-URL: Homepage, https://github.com/episodely/tokenwise
Project-URL: Issues, https://github.com/episodely/tokenwise/issues
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Operating System :: OS Independent
Requires-Python: >=3.8
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: license-file

# tokenwise

Estimate how many tokens a prompt is and what it costs on popular LLMs. Pure Python, no dependencies, no network.

```
$ echo "Summarize this article in three bullet points." | python -m tokenwise
~12 tokens (46 chars)
  gemini-flash   $0.000001
  ...
```

## Install

```
pip install tokenwise-py
```

Or copy `tokenwise.py` into your project, it has no dependencies.

## Usage

```
python -m tokenwise prompt.txt --out 500      # include expected output tokens
python -m tokenwise prompt.txt --json
```

```python
from tokenwise import estimate_tokens, cost
n = estimate_tokens(text)
cost(n, 500, "claude-sonnet")
```

## Accuracy

It is a heuristic (chars/4 and word-piece blend, denser for non-Latin scripts like Arabic). Expect roughly 15% error against real tokenizers. Good for budgeting, not billing. Prices live in the `PRICES` dict at the top of `tokenwise.py`; update them to match current provider pricing.

## Test

```
python -m pytest
```

MIT licensed.
