Function Calling / Tool-Use Token Cost Calculator
Paste your tool definitions and see the hidden cost of re-sending them on every LLM API call — per model, with and without prompt caching, plus the saving from trimming verbose schemas. Counts run in your browser; no API key, no signup.
How it works
Large language models are stateless, so the full set of tool (function) definitions you give a model is serialized into the request and re-sent on every single call. Those definitions are billed as input tokens: Anthropic's token-counting API returns input counts that include the tools array, and OpenAI's token-counting cookbook documents that function definitions are injected into the prompt and counted as input. A schema that looks trivial can quietly dominate your bill once it is multiplied across high call volume.
The calculator works in four steps:
- Count tool-definition tokens.Your pasted JSON is tokenized in the browser with gpt-tokenizer (the JavaScript port of OpenAI's tiktoken,
cl100k_base) to get the per-call overhead, plus a per-tool breakdown so you can spot the bloated one. - Project monthly tokens. Per-call tool tokens × calls per month gives the monthly tool-definition input tokens.
- Apply the price. Monthly cost =
tool_tokens × calls ÷ 1,000,000 × input_$/1M. With prompt caching, the stable tools prefix bills at the cache-read rate (≈0.1× the input rate on Anthropic) instead, which the caching toggle applies. - Compare and trim. The same token count is priced across every model so you see the pure price spread, and the trim simulator shows the monthly saving from cutting your schemas to a target size.
The share of input billfigure divides the tool-definition cost by the total input cost (tool definitions + conversation), both at the full input rate, so you can see what fraction of your input spend is just re-sent definitions. Token counts are in-browser estimates — Anthropic's own tokenizer counts about 10–15% higher on the same JSON, so for a Claude figure to the token use Anthropic's count_tokens endpoint. The dollar arithmetic is exact for whatever token count you supply, and every monthly figure is cross-checked by an independent per-call calculation.
Worked examples
Frequently asked questions
Sources & references
- Anthropic — Token Counting API (counts include the tools array)
- Anthropic — Tool use overview (tool definitions billed as input)
- Anthropic — Pricing (input/output rates; cache reads ≈ 0.1× input)
- OpenAI — Cookbook: how to count tokens (tool definitions are input)
- OpenAI — API pricing
- Google — Gemini API pricing
Prices and the token-counting method were last cross-checked against the cited sources on 2026-06-19. Anthropic rates are verified against the Anthropic pricing page; OpenAI and Gemini rows are published list prices that change without notice. Token counts are in-browser estimates — for billing-exact Claude counts, use Anthropic's count_tokens endpoint.
Related tools
Comments & feedback
Spotted a bug or want an improvement? Tell us — our team reviews every comment, and good ideas get built. Comments are public and anonymous.
Found a bug, edge case, or want to suggest an improvement?
Email me at [email protected] — most fixes ship within 24 hours.