{"success":true,"version":"v1","request":{"tool":"get_calculator_schema","calculator_id":"llm-token-cost"},"result":{"entity_type":"calculator","id":"llm-token-cost","calculator_id":"llm-token-cost","canonical_url":"https://tttkmbb.com/developer/llm-token-cost","name":"LLM Token Cost Calculator","title":"LLM API Cost Calculator – Price per Request and Total from Input, Output and Cached Tokens","category":"developer","category_name":"Developer & IT","tool_name":"calculate_llm_token_cost","featured_mcp_tool":false,"description":"Computes the cost of large-language-model API calls from the number of input, cached-input and output tokens per request, the prices per million tokens supplied by the caller, and the number of requests.","use_when":"You are budgeting an LLM feature, comparing providers at their published per-million-token prices, or estimating the monthly bill for a given request volume.","do_not_use_when":"You need token counts from text (tokenizers are model-specific; roughly 4 characters per token in English), or provider-specific extras such as batch discounts, image tokens or fine-tuning fees.","inputs":[{"name":"input_tokens","label":"Input tokens per request","type":"integer","unit":"tokens","required":true,"min":0,"max":1000000000,"description":"Prompt tokens per request, including any cached portion.","example":1000},{"name":"output_tokens","label":"Output tokens per request","type":"integer","unit":"tokens","required":true,"min":0,"max":1000000000,"description":"Completion tokens per request.","example":500},{"name":"price_input_per_million","label":"Input price","type":"number","unit":"per 1M tokens","required":true,"min":0,"max":100000,"description":"Price per million uncached input tokens, in your currency.","example":3},{"name":"price_output_per_million","label":"Output price","type":"number","unit":"per 1M tokens","required":true,"min":0,"max":100000,"description":"Price per million output tokens.","example":15},{"name":"requests","label":"Requests","type":"integer","required":false,"default":1,"min":1,"max":1000000000000,"description":"Number of requests (e.g. per month).","example":10000},{"name":"cached_input_tokens","label":"Cached input tokens per request","type":"integer","unit":"tokens","required":false,"default":0,"min":0,"max":1000000000,"description":"Part of input_tokens served from a prompt cache and billed at price_cached_per_million.","example":0},{"name":"price_cached_per_million","label":"Cached input price","type":"number","unit":"per 1M tokens","required":false,"default":0,"min":0,"max":100000,"description":"Price per million cached input tokens (often 10–50 % of the input price).","example":0}],"outputs":[{"name":"input_cost","label":"Input cost per request","type":"number","decimals":6,"description":"(input_tokens − cached_input_tokens) × price_input_per_million / 10⁶."},{"name":"cached_cost","label":"Cached input cost per request","type":"number","decimals":6,"description":"cached_input_tokens × price_cached_per_million / 10⁶."},{"name":"output_cost","label":"Output cost per request","type":"number","decimals":6,"description":"output_tokens × price_output_per_million / 10⁶."},{"name":"cost_per_request","label":"Cost per request","type":"number","decimals":6,"description":"Sum of the three per-request components."},{"name":"total_cost","label":"Total cost","type":"number","decimals":2,"description":"cost_per_request × requests."},{"name":"cost_per_1000_requests","label":"Cost per 1,000 requests","type":"number","decimals":2,"description":"cost_per_request × 1000."},{"name":"tokens_per_request","label":"Tokens per request","type":"integer","unit":"tokens","decimals":4,"description":"input_tokens + output_tokens."},{"name":"total_tokens","label":"Total tokens","type":"integer","unit":"tokens","decimals":0,"description":"tokens_per_request × requests."},{"name":"blended_price_per_million","label":"Blended price","type":"number","unit":"per 1M tokens","decimals":4,"description":"total_cost / total_tokens × 10⁶: the effective price per million tokens of the mix."},{"name":"output_share_percent","label":"Output share of cost","type":"number","unit":"%","decimals":2,"description":"Output cost as a percentage of the cost per request."}],"input_schema":{"type":"object","properties":{"input_tokens":{"description":"Prompt tokens per request, including any cached portion. Unit: tokens.","type":"integer","minimum":0,"maximum":1000000000,"examples":[1000],"x-unit":"tokens"},"output_tokens":{"description":"Completion tokens per request. Unit: tokens.","type":"integer","minimum":0,"maximum":1000000000,"examples":[500],"x-unit":"tokens"},"price_input_per_million":{"description":"Price per million uncached input tokens, in your currency. Unit: per 1M tokens.","type":"number","minimum":0,"maximum":100000,"examples":[3],"x-unit":"per 1M tokens"},"price_output_per_million":{"description":"Price per million output tokens. Unit: per 1M tokens.","type":"number","minimum":0,"maximum":100000,"examples":[15],"x-unit":"per 1M tokens"},"requests":{"description":"Number of requests (e.g. per month).","type":"integer","minimum":1,"maximum":1000000000000,"default":1,"examples":[10000]},"cached_input_tokens":{"description":"Part of input_tokens served from a prompt cache and billed at price_cached_per_million. Unit: tokens.","type":"integer","minimum":0,"maximum":1000000000,"default":0,"examples":[0],"x-unit":"tokens"},"price_cached_per_million":{"description":"Price per million cached input tokens (often 10–50 % of the input price). Unit: per 1M tokens.","type":"number","minimum":0,"maximum":100000,"default":0,"examples":[0],"x-unit":"per 1M tokens"}},"additionalProperties":false,"required":["input_tokens","output_tokens","price_input_per_million","price_output_per_million"]},"output_schema":{"type":"object","properties":{"input_cost":{"description":"(input_tokens − cached_input_tokens) × price_input_per_million / 10⁶.","type":"number"},"cached_cost":{"description":"cached_input_tokens × price_cached_per_million / 10⁶.","type":"number"},"output_cost":{"description":"output_tokens × price_output_per_million / 10⁶.","type":"number"},"cost_per_request":{"description":"Sum of the three per-request components.","type":"number"},"total_cost":{"description":"cost_per_request × requests.","type":"number"},"cost_per_1000_requests":{"description":"cost_per_request × 1000.","type":"number"},"tokens_per_request":{"description":"input_tokens + output_tokens. Unit: tokens.","type":"integer","x-unit":"tokens"},"total_tokens":{"description":"tokens_per_request × requests. Unit: tokens.","type":"integer","x-unit":"tokens"},"blended_price_per_million":{"description":"total_cost / total_tokens × 10⁶: the effective price per million tokens of the mix. Unit: per 1M tokens.","type":"number","x-unit":"per 1M tokens"},"output_share_percent":{"description":"Output cost as a percentage of the cost per request. Unit: %.","type":"number","x-unit":"%"}}},"formula":"cost_per_request = (input_tokens − cached_input_tokens) × p_in / 10⁶ + cached_input_tokens × p_cached / 10⁶ + output_tokens × p_out / 10⁶; total_cost = cost_per_request × requests","method":"Pure multiplication with caller-supplied prices in any currency; no price list is built in, so check the provider's current published rates. Cached tokens must not exceed input tokens.","sources":[{"name":"OpenAI Help Center – What are tokens and how to count them?","url":"https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them","type":"reference","retrieved_at":"2026-09-24"},{"name":"Byte pair encoding (Wikipedia)","url":"https://en.wikipedia.org/wiki/Byte_pair_encoding","type":"reference","retrieved_at":"2026-09-24"}],"freshness":{"type":"static","max_age_seconds":null,"note":"Deterministic formula with fixed constants; results never go stale. Inputs supplied by the caller determine the output."},"examples":[{"name":"1,000 in / 500 out at 3 and 15 per million, one request","inputs":{"input_tokens":1000,"output_tokens":500,"price_input_per_million":3,"price_output_per_million":15,"requests":1},"expected":{"input_cost":0.003,"output_cost":0.0075,"cost_per_request":0.0105,"total_cost":0.01,"tokens_per_request":1500,"output_share_percent":71.43},"url":"https://tttkmbb.com/api/v1/calculate/llm-token-cost?input_tokens=1000&output_tokens=500&price_input_per_million=3&price_output_per_million=15&requests=1"},{"name":"Same request 10,000 times","inputs":{"input_tokens":1000,"output_tokens":500,"price_input_per_million":3,"price_output_per_million":15,"requests":10000},"expected":{"total_cost":105,"cost_per_1000_requests":10.5,"total_tokens":15000000,"blended_price_per_million":7},"url":"https://tttkmbb.com/api/v1/calculate/llm-token-cost?input_tokens=1000&output_tokens=500&price_input_per_million=3&price_output_per_million=15&requests=10000"}],"faq":[{"q":"How do I count tokens?","a":"Use the provider's tokenizer (tiktoken for OpenAI models, the Anthropic token-count endpoint); as a rule of thumb one token is about 4 English characters or ¾ of a word."},{"q":"How is prompt caching modelled?","a":"cached_input_tokens is the part of each request's prompt billed at the cheaper cached rate; the remainder pays the full input price. Cache-write surcharges are not modelled."},{"q":"Why are output tokens so much more expensive?","a":"Generation is sequential (one forward pass per token) while prompt tokens are processed in parallel, so providers price output 3–5× higher than input."}],"tags":["llm cost","token pricing","api cost calculator","gpt cost","claude cost","tokens per million"],"related":[{"calculator_id":"llm-vram-estimate","reason":"Memory needed to self-host instead of paying per token."},{"calculator_id":"percentage","reason":"Percent arithmetic for discounts and shares."},{"calculator_id":"reading-time","reason":"Words (≈ tokens × 0.75) to reading time."}],"links":{"html":"https://tttkmbb.com/developer/llm-token-cost","markdown":"https://tttkmbb.com/developer/llm-token-cost.md","json":"https://tttkmbb.com/developer/llm-token-cost.json","api":"https://tttkmbb.com/api/v1/calculate/llm-token-cost","schema":"https://tttkmbb.com/api/v1/calculators/llm-token-cost","openapi":"https://tttkmbb.com/openapi.json","mcp":"https://tttkmbb.com/mcp"},"version":"v1","updated_at":"2026-09-24"},"timestamp":"2026-09-24T03:46:20Z","next_actions":[{"tool":"run_calculator","calculator_id":"llm-token-cost","reason":"Run LLM Token Cost Calculator with the inputs above."}],"links":{"markdown":"https://tttkmbb.com/developer/llm-token-cost.md"}}