Skip to main content

dhrions-llm-usage

Tarification, comptage de tokens et affichage LLM partagés entre plusieurs CLI.

Quand plusieurs outils appellent un LLM et affichent le modèle utilisé, les tokens consommés et un coût estimé, chacun tend à réimplémenter sa propre table de prix et son propre format. Ce paquet centralise ces trois responsabilités : une source de prix unique, un cumul d'usage thread-safe, un rendu cohérent.

Le paquet importable est llm_usage et la commande installée est llm-usage.

Installation

pip install dhrions-llm-usage

Contenu

Module Rôle
pricing Table de prix (par token, au jeton de sortie seul pour l'image, et forfait par unité) + repli pour modèle inconnu.
accumulator Usage : cumul thread-safe des tokens par modèle, et calcul du coût.
display Rendu texte au style FR (format_cost, format_usage_line, model_line).

Utilisation

from llm_usage import Usage, format_usage_line, model_line

usage = Usage()
usage.add("claude-opus-4-8", input_tokens=12000, output_tokens=3400)

print(model_line("claude-opus-4-8"))
# 🧠 Modèle utilisé : claude-opus-4-8
print(format_usage_line(usage))
# 📊 15 400 tokens (entrée 12 000 / sortie 3 400) · ~0,1450 $

Inspecter la table de prix depuis la ligne de commande :

llm-usage prices

Convention d'affichage (style FR)

  • montant puis symbole, séparateur décimal virgule : 0,0042 $ ;
  • ~ en préfixe pour une estimation, ≥ quand un montant est minoré (modèle non tarifé) ;
  • tokens : entrée X / sortie Y, milliers groupés par une espace fine ;
  • annonce systématique du modèle : 🧠 Modèle utilisé : ….

Licence

MIT.

Metadata

Release files for dhrions-llm-usage 0.2.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for dhrions-llm-usage 0.2.2
File Size Uploaded Provenance Actions
dhrions_llm_usage-0.2.2.tar.gz 10.1 kB Without provenance Details for dhrions_llm_usage-0.2.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for dhrions-llm-usage 0.2.2
File Interpreter ABI Platform Actions
dhrions_llm_usage-0.2.2-py3-none-any.whl Python 3 none any Details for dhrions_llm_usage-0.2.2-py3-none-any.whl

Total release size: 18.7 kB

Release files / dhrions_llm_usage-0.2.2.tar.gz

Download URL dhrions_llm_usage-0.2.2.tar.gz
Size 10.1 kB
Tags Source
SHA-256 checksum
How to use checksums
f404d27825196331eb64f8c5e2ba27fab0fdde4266687ad84c828f7ba01358ac
BLAKE2b-256 checksum
How to use checksums
010f57177a88704e7c39fd8cb101c760efc7c2c5228c33eed9f5b8cdf148a23f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / dhrions_llm_usage-0.2.2-py3-none-any.whl

Download URL dhrions_llm_usage-0.2.2-py3-none-any.whl
Size 8.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
302612494529d3dbab7a2e572343eb892746fb20052b645a80735be6135043c3
BLAKE2b-256 checksum
How to use checksums
93855cc4c08fa06231122be3f4fe54f9a74d97131d9079956df847a662a2e607
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Security for dhrions-llm-usage 0.2.2

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.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page