Metadata-Version: 2.4
Name: mamood-llm-cost-estimator
Version: 0.1.0
Summary: Realtime OpenRouter LLM API call cost estimator
Keywords: llm,openrouter,cost,token,estimator
Author: Amirhossein Mahmoudi
Author-email: Amirhossein Mahmoudi <am.mahmoudi@outlook.com>
License-Expression: MIT
Classifier: Development Status :: 3 - Alpha
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.12
Project-URL: Homepage, https://github.com/ammahmoudi/mamood_llm_cost_estimator
Project-URL: Repository, https://github.com/ammahmoudi/mamood_llm_cost_estimator
Description-Content-Type: text/markdown

# mamood-llm-cost-estimator

Realtime OpenRouter LLM API call cost estimator for Python.

## Features

- Fetches live model pricing from OpenRouter.
- Estimates input, cached input, output, and total call cost.
- Works as both a Python library and a CLI.
- Built and managed with `uv`.
- Uses OpenRouter public `/models` endpoint for pricing (API key optional).

## Install

```bash
uv add mamood-llm-cost-estimator
```

Or from source:

```bash
uv sync
```

## Python usage

```python
from mamood_llm_cost_estimator import OpenRouterClient, TokenUsage

client = OpenRouterClient(api_key="YOUR_OPENROUTER_API_KEY")
usage = TokenUsage(input_tokens=1500, output_tokens=700, cached_input_tokens=300)

cost = client.estimate_model_cost(model="openai/gpt-4o-mini", usage=usage)
print(cost.as_dict())

models = client.list_models()
first = models[0]
print(first.id, first.provider, first.context_window, first.input_price_per_million_usd)
```

## CLI usage

```bash
mamood-cost \
  --model openai/gpt-4o-mini \
  --input-tokens 1500 \
  --output-tokens 700 \
  --cached-input-tokens 300 \
  --api-key "$OPENROUTER_API_KEY"
```

## Dev setup

```bash
uv sync
uv run python -m mamood_llm_cost_estimator --help
```

## Build & publish to PyPI

1. Set your version in `pyproject.toml`.
2. Build distributions:

	```bash
	uv build
	```

3. Publish (token-based):

	```bash
	uv publish --token <PYPI_TOKEN>
	```

Project owner: Amirhossein Mahmoudi (@ammahmoudi)

