Skip to main content

Calculate LLM token costs from llmlite pricing data

Project description

llmcalc

llmcalc is a Python package to calculate LLM token costs from llmlite pricing data.

Install

pip install llmcalc

Python usage

import asyncio
from llmcalc import calculate_token_cost

result = asyncio.run(calculate_token_cost("gpt-4o-mini", 1200, 800))
if result:
    print(result.total_cost)

CLI usage

llmcalc quote --model gpt-4o-mini --input 1200 --output 800
llmcalc model --model gpt-4o-mini --json
llmcalc cache clear
llmcalc --version

Defaults

  • Default cache TTL is 43200 seconds (12 hours).
  • Override cache TTL with LLMCALC_CACHE_TIMEOUT.
  • Override pricing source with LLMCALC_PRICING_URL.
  • Set fallback currency label with LLMCALC_CURRENCY (used only when upstream omits currency).

Release Validation

python -m build --no-isolation
python -m twine check dist/*

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

llmcalc-0.1.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

llmcalc-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file llmcalc-0.1.0.tar.gz.

File metadata

  • Download URL: llmcalc-0.1.0.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for llmcalc-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6d639790104e0d5b9d2f36ddf1c39f888fc547bebe025a9fe7a6242ba9f63965
MD5 9bd9369718eb8fd6e8471308a8497b30
BLAKE2b-256 35844e9426b3c1f9bfe1fe97793b9d9aa1e754ef893f7d0ac1d816558e9b2580

See more details on using hashes here.

File details

Details for the file llmcalc-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: llmcalc-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.14

File hashes

Hashes for llmcalc-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c2dca54118d1f2126eba6441c21d57faf34cabfa07c81fdb788aea87b2e62056
MD5 a5e1774ca0f1bb7a41a8cadea17ebe46
BLAKE2b-256 46a516c3c6762ff160a3b42e590fcc6047a13879aa751573e826aebef0c17262

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page