{"categories":[{"label":"Artificial Intelligence","url":"https://skillfed.io/packages/category/scientific-engineering-artificial-intelligence/6"}],"enrichment":{"capability":"Counts tokens and estimates USD costs for LLM API calls across OpenAI, Anthropic, and other major providers before or after requests are sent.","skillfed_tags":["llm-cost-tracking","token-counting","api-pricing"],"use_cases":["Estimate the cost of a prompt before sending it to OpenAI or Anthropic to stay within budget.","Track total token costs in an AI agent that makes multiple LLM calls across different models.","Count tokens in a string or message list without making an API call, using tiktoken directly.","Compare pricing across different LLM models to choose the most cost-effective option for a task.","Log and report spending on LLM APIs in production applications."],"what_it_does":"TokenCost is a client-side utility for estimating the USD cost of LLM API calls by counting tokens and applying current pricing. It wraps OpenAI's tiktoken tokenizer for accurate token counting on OpenAI and older Claude models, and uses Anthropic's beta token counting API for Claude 3 and later. The package maintains a pricing table for major LLM providers and exposes simple functions to calculate prompt and completion costs from either message-formatted lists or raw strings.\n\nYou use it to estimate costs before sending requests to an LLM API, or to calculate the cost of responses you've already received. It integrates with the OpenAI and Anthropic client libraries and is commonly used in AI agent frameworks to track spending. The package depends on tiktoken, aiohttp, and anthropic as runtime dependencies.","worth_installing":"Yes, if you build with LLM APIs and need cost visibility before or after requests. The package is straightforward, permissively licensed, and has low install friction. However, be aware that maintenance is aging\u2014pricing tables may lag behind provider updates, and support for newly released models is not guaranteed. Verify that the models you use are in the pricing table before relying on it for cost estimates."},"id":"tokencost","links":{"html":"https://skillfed.io/packages/tokencost","md":"https://skillfed.io/packages/tokencost.md","pypi":"https://pypi.org/project/tokencost/"},"maintenance":{"status":"aging"},"meta":{"latest_release":"2025-08-13","license_spdx":null,"license_treatment":"permissive","name":"tokencost","python_support":"supports_current","summary":"To calculate token and translated USD cost of string and message calls to OpenAI, for example when used by AI agents"},"popularity":{"monthly_downloads":396149,"position":6971,"tier":"top_15000"},"security":{"n_vulnerabilities":0},"version":"0.1.26"}
