Pricing + release metadata and cost estimation for LLMs
Project description
llm-price
Pricing + release metadata and cost estimation for LLMs (OpenAI + Google Gemini).
Features
- Model metadata with release dates
- Static pricing in USD per 1M tokens
- Cost estimation from token counts or raw text
- USD or INR output (you supply FX rate)
- CLI for listing models and summing JSONL usage
Install
pip install llm-price
Quickstart (Python)
from decimal import Decimal
from llm_price import cost_from_text, cost_from_tokens, list_models
models = list_models("openai")
print(models[0])
cost = cost_from_text(
"openai",
"gpt-4o-mini",
prompt="Summarize this text.",
completion="Here is a summary...",
)
print(cost.total_cost)
cost_in_inr = cost_from_tokens(
"google",
"gemini-1.5-flash",
prompt_tokens=120,
completion_tokens=40,
currency="INR",
fx_usd_to_inr=Decimal("83.12"),
)
print(cost_in_inr.total_cost)
CLI
llm-price models --provider openai
llm-price cost \
--provider openai \
--model gpt-4o-mini \
--prompt "Hello" \
--completion "Hi" \
--currency USD
llm-price cost \
--provider google \
--model gemini-1.5-flash \
--prompt-tokens 100 \
--completion-tokens 20 \
--currency INR \
--fx-usd-inr "83.12"
JSONL Summation
llm-price sum usage.jsonl supports lines with:
Token counts
{"provider":"openai","model":"gpt-4o-mini","prompt_tokens":1200,"completion_tokens":400}
Raw text (tokenized internally)
{"provider":"openai","model":"gpt-4o-mini","prompt":"Hello","completion":"Hi"}
Pre-computed totals
{"total_cost":{"amount":"0.0123","currency":"USD"}}
Example Scripts
Run these from the repo root after installing dependencies:
python examples/basic_cost.py
python examples/inr_conversion.py
python examples/sum_jsonl.py
Notes
- Pricing data is stored in
src/llm_price/data/models.jsonin USD per 1M tokens. - For INR output you must supply an FX rate (
fx_usd_to_inr). - Gemini token counting uses the official CountTokens API when
GOOGLE_API_KEYis set; otherwise it falls back to an approximation.
Development
pip install -e ".[dev]"
pytest
Release (PyPI)
This project uses GitHub Actions trusted publishing. Create a tag like v0.1.0
and push it to GitHub to trigger the publish workflow:
git tag v0.1.0
git push origin v0.1.0
Configure the PyPI Trusted Publisher with:
- PyPI Project Name:
llm-price - Owner:
VA24d - Repository name:
API-price - Workflow name:
publish.yml - Environment name:
pypi
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file llm_price-0.1.0.tar.gz.
File metadata
- Download URL: llm_price-0.1.0.tar.gz
- Upload date:
- Size: 8.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1ade02c203a252575c4332c86524689dc471189fbdcd1c02f3a5ecf60bf54ac4
|
|
| MD5 |
6a2f688274571939b7edf7217eac37c0
|
|
| BLAKE2b-256 |
0709c2681e631de6a3ba810bf8bd67d1881e190015d98c8ef15fa660e4b4c91c
|
Provenance
The following attestation bundles were made for llm_price-0.1.0.tar.gz:
Publisher:
publish.yml on VA24d/API-price
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_price-0.1.0.tar.gz -
Subject digest:
1ade02c203a252575c4332c86524689dc471189fbdcd1c02f3a5ecf60bf54ac4 - Sigstore transparency entry: 928460352
- Sigstore integration time:
-
Permalink:
VA24d/API-price@12a686d8f39da952cc87eed54acdae64f596b8ef -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/VA24d
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@12a686d8f39da952cc87eed54acdae64f596b8ef -
Trigger Event:
push
-
Statement type:
File details
Details for the file llm_price-0.1.0-py3-none-any.whl.
File metadata
- Download URL: llm_price-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a5f22256148feda7c9dedb3b37c45031721f6b6dc360a4f4d211544acdf11fe4
|
|
| MD5 |
e71e195d75d37236f9d51c078a1919f9
|
|
| BLAKE2b-256 |
eb3fdeb868a5cb651f4fef57026c80e211e1aad6dd9e5b2b3d8f22e880840f9c
|
Provenance
The following attestation bundles were made for llm_price-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on VA24d/API-price
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
llm_price-0.1.0-py3-none-any.whl -
Subject digest:
a5f22256148feda7c9dedb3b37c45031721f6b6dc360a4f4d211544acdf11fe4 - Sigstore transparency entry: 928460353
- Sigstore integration time:
-
Permalink:
VA24d/API-price@12a686d8f39da952cc87eed54acdae64f596b8ef -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/VA24d
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@12a686d8f39da952cc87eed54acdae64f596b8ef -
Trigger Event:
push
-
Statement type: