Skip to content
Calm motion: animations on this site only fade, with no movement

Token cost ​

The tokens of a request and what they cost

Shows what one request to a language model costs, in a developer console, a usage page, or a debug panel. For how full the context window is, use the context meter.

Basic
Cost of the request, Example model
TokensCountPrice per millionCost
Input1,840$3.00$0.00552
Cached input12,000$0.30$0.0036
Output620$15.00$0.0093
Total14,460$0.0184
  • usage has the input and output tokens, and optional cached input tokens. Cached tokens are not part of input.
  • prices are the prices for one million tokens of each kind. If cached has no price, it costs the same as input.
  • The table shows the count, the price, and the cost of each kind, and the total in the footer.
  • A cost that fits in cents shows as usual. A smaller cost keeps three digits that count, such as $0.0036, so it does not show as $0.00.
  • currency (default USD) and locale format the money and the counts. model goes in the caption.
  • Change the words with labels or a label pack. The API table lists the keys.

The tokenCost function does the math. It is exported for your own views, such as a total for a month.

Usage ​

ts
import { BlessTokenCost } from "blessing-ui";

API ​

Props

NameTypeDefaultDescription
usage*BlessTokenUsage—
prices*BlessTokenPrices—
modelstring—the model, for the caption
currencystring"USD"
localestring"en"
labelsPartial<{ caption: (model?: string | undefined) => string; kind: string; tokens: string; price: string; cost: string; input: string; cached: string; output: string; total: string; }>—

Released under the MIT License. Character names and artwork belong to their owners.