Skip to main content

CLI

@tensorcost/cli estimates and compares LLM prompt costs from a terminal or CI job. It ships with bundled, offline pricing data — no API key or network access required to get a number.
This is a standalone estimation tool, not the way you connect an account to TensorCost. For that, see get started. If you want live cost observability for calls your app is already making, see developer tools.

Install

Both tensorcost and tc are registered as binary names after a global install:

estimate

Estimate the cost of a single prompt invocation.

compare

Compare cost between a baseline and a candidate prompt — useful for a “does my prompt-engineering change cost more?” check before you ship it.

models

List every bundled model and its current rate.
Covers Anthropic, OpenAI, AWS Bedrock, Google Vertex, and Azure OpenAI model IDs. Run tensorcost models --json for the last_updated field per model — a few less-common models are marked in the CLI’s own output as not yet confirmed against the provider’s pricing page, so check there before relying on those specific figures.

Live rates (optional)

By default everything runs offline against the bundled pricing table. Set TENSORCOST_API_KEY and the CLI fetches live rates — including any negotiated discount on your account — on each invocation, cached for an hour at ~/.tensorcost/rates-cache.json. If the key is absent, the network is unreachable, or the request fails, the CLI falls back to the bundled table silently — offline use is never blocked.

Tokenization

Token counts are estimated using ceil(charCount / 4) by default, accurate to within roughly 10% for typical English text. If tiktoken or @anthropic-ai/tokenizer is installed alongside the CLI, it’s used automatically — no configuration needed.

CI usage

Both estimate and compare accept --json:
A common pattern is a Makefile target that fails a PR if a prompt change costs meaningfully more: