Skip to main content

A lightweight library to fetch and search AI model pricing data

Project description

Valuator

A lightweight Python library to fetch AI model pricing data and perform searches to retrieve input and output costs per token for matching models.

Installation

pip install valuator

Usage

import asyncio
from valuator import Valuator

async def main():
    valuator = Valuator()
    try:
        # Initialize with default force_refresh=True to fetch latest data
        await valuator.initialize()
        print(valuator.get_model_costs("claude.*haiku"))
        print(valuator.get_model_costs("gpt-4"))
        # Use force_refresh=False to prefer cache if unchanged
        await valuator.initialize(force_refresh=False)
        print(valuator.get_model_costs("gpt.*"))
    finally:
        await valuator.close()

asyncio.run(main())

Features

  • Fetches model pricing data.
  • Automatically checks if the remote JSON has changed using ETag headers.
  • Defaults to fetching the latest data (force_refresh=True) to ensure up-to-date model prices.
  • Performs regex-based searches on model names for flexible matching.
  • Returns only input_cost_per_token and output_cost_per_token for matched models.
  • Optimized for low memory usage with efficient data structures (sets, cached regex).
  • Asynchronous HTTP requests for fast data retrieval.

Requirements

  • Python 3.8+
  • aiohttp>=3.8.0

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

valuator-0.2.3.tar.gz (3.8 kB view details)

Uploaded Source

Built Distribution

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

valuator-0.2.3-py3-none-any.whl (4.2 kB view details)

Uploaded Python 3

File details

Details for the file valuator-0.2.3.tar.gz.

File metadata

  • Download URL: valuator-0.2.3.tar.gz
  • Upload date:
  • Size: 3.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for valuator-0.2.3.tar.gz
Algorithm Hash digest
SHA256 23639bf949612c6687e8650132e58ef8533e7539f90965abfeb02c333b0c9623
MD5 8b832e7c83dd42f076aaeccf77c5a949
BLAKE2b-256 3bd2a6f2142a2a12288ab781a19e796871127eb656dd6d03551725b6c80fc3bd

See more details on using hashes here.

File details

Details for the file valuator-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: valuator-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 4.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for valuator-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 dbd2b9920d9348f3510a637df6add6574f17aec913b917080a6ae8fd7ea1d803
MD5 f9fb89b4fd31f1c162ff3da8324a8a3a
BLAKE2b-256 cf24f416a64d0659ef826455c5db9d02e1324b6e96a7d7a82a6c6fe9e94d697e

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