Skip to main content

A package to calculate token costs for LLM models

Project description

LLM Model Cost Calculator

A Python package to calculate token costs for various LLM models based on input and output tokens.

Installation

pip install llm_model_cost

Usage

from llm_model_cost import ModelCost

# Calculate cost for a model
costInfo = ModelCost(name="gpt-4", input_tokens=100, output_tokens=50)

# Get cost details
print(f"Input cost: ${costInfo.input_cost:.6f}")
print(f"Output cost: ${costInfo.output_cost:.6f}")
print(f"Total cost: ${costInfo.cost:.6f}")

# Get model information
model_info = ModelCost.get_model_info("gpt-4")
print(f"Max tokens: {model_info['max_tokens']}")
print(f"Provider: {model_info['litellm_provider']}")


# List all available models
models = ModelCost.list_models()

Features

  • Calculate token costs for various LLM models
  • Get model information including max tokens, costs, and provider details
  • List all available models and their capabilities
  • Automatic updates from the latest pricing data

License

MIT License

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

llm_model_cost-1.0.0.tar.gz (3.3 kB view details)

Uploaded Source

Built Distribution

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

llm_model_cost-1.0.0-py3-none-any.whl (3.8 kB view details)

Uploaded Python 3

File details

Details for the file llm_model_cost-1.0.0.tar.gz.

File metadata

  • Download URL: llm_model_cost-1.0.0.tar.gz
  • Upload date:
  • Size: 3.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for llm_model_cost-1.0.0.tar.gz
Algorithm Hash digest
SHA256 7ce336fb616d05f2dfff6552fa6fe77b1dd729598647ceddcfbe8f4c5631d661
MD5 47e672290543695a8e922f9a6fb73c7c
BLAKE2b-256 0cbec2e9668d796293eff2c443f5b1528c8c79a86a48657bcb47b538d8015f1f

See more details on using hashes here.

File details

Details for the file llm_model_cost-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: llm_model_cost-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 3.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for llm_model_cost-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5b80253aaf65f67a62aec470cff2179a3fc934da80fbf9d5a4016312890d713
MD5 fd6e6c02d0659141a2b67071cd7cbb45
BLAKE2b-256 4b6287c508810bfb2b929e0d3d3d8813cbc77b3fbcb19342c3a7c12bc2b28356

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