pricetoken
Real-time LLM pricing data — typed client, cost calculator, and static pricing.
Python SDK for PriceToken. Zero runtime dependencies.
Install
pip install pricetoken
# or
uv add pricetoken
Quick Start
Calculate cost offline (no API call)
from pricetoken import calculate_model_cost
cost = calculate_model_cost("claude-sonnet-4-6", 1_000_000, 100_000)
print(cost.total_cost) # $4.50
Fetch live pricing
from pricetoken import PriceTokenClient
client = PriceTokenClient()
pricing = client.get_pricing()
for model in pricing:
print(f"{model.display_name}: ${model.input_per_m_tok}/MTok in, ${model.output_per_m_tok}/MTok out")
With API key (higher rate limits)
client = PriceTokenClient(api_key="pt_your_key_here")
Cost Calculation
from pricetoken import calculate_cost, calculate_model_cost
# By model ID (uses bundled static pricing)
cost = calculate_model_cost("gpt-4.1", 500_000, 100_000)
print(cost.input_cost) # $1.00
print(cost.output_cost) # $0.80
print(cost.total_cost) # $1.80
# With explicit rates
cost = calculate_cost("custom-model", 5.0, 15.0, 1_000_000, 500_000)
print(cost.total_cost) # $12.50
Static Pricing Data
21 models from Anthropic, OpenAI, Google, and DeepSeek are bundled for offline use:
from pricetoken import STATIC_PRICING
for model in STATIC_PRICING:
print(f"{model.model_id}: ${model.input_per_m_tok}/MTok")
Note: Static data reflects prices at the time the package was published and does not auto-update. For the latest prices, use
PriceTokenClientto fetch live data from the API.
API Reference
| Method | API Path |
|---|---|
get_pricing(provider=, currency=) |
GET /api/v1/text |
get_model(model_id, currency=) |
GET /api/v1/text/{model_id} |
get_history(days=, model_id=, provider=) |
GET /api/v1/text/history |
get_providers() |
GET /api/v1/text/providers |
compare(model_ids, currency=) |
GET /api/v1/text/compare |
get_cheapest(provider=, currency=) |
GET /api/v1/text/cheapest |
Types
All types are dataclass(slots=True) for performance and type safety:
ModelPricing— model pricing dataCostEstimate— cost calculation resultPriceHistoryPoint— historical price data pointModelHistory— price history for a modelProviderSummary— provider overview with statsPriceTokenError— API error (extendsException)
Type aliases: ModelStatus, DataConfidence, Source (all Literal types).
Requirements
- Python >= 3.10
- Zero runtime dependencies
License
MIT
Metadata
Release files for pricetoken 0.13.10
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| pricetoken-0.13.10.tar.gz | 46.4 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| pricetoken-0.13.10-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 73.7 kB
Release files / pricetoken-0.13.10.tar.gz
| Download URL | pricetoken-0.13.10.tar.gz |
|---|---|
| Size | 46.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
de1b95a38149690cd43d796f8be17ed9dea67e1551b91bf90b8e541bf9c8c098
|
|
BLAKE2b-256 checksum How to use checksums |
e73e3b1e890e426626ada282daa0de8b67cd379892e7b8b8cdb33928d222aa99
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Release files / pricetoken-0.13.10-py3-none-any.whl
| Download URL | pricetoken-0.13.10-py3-none-any.whl |
|---|---|
| Size | 27.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
13afdd24c285f39c8f329b99256b9b02089ed2ac6201729121ad6b9912c3530d
|
|
BLAKE2b-256 checksum How to use checksums |
2eff9354fafa9002143b7bc12dda03a90a0d8890a2893d8335a1e6ab7df5d7c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.10.12 {"installer":{"name":"uv","version":"0.10.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}
|
Security for pricetoken 0.13.10
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.