Skip to main content

Overview

Formal estimates the cost of every LLM request from token prices you set. Each log carries the cost, and policies read it. Policies also see each user’s spend and token count, so you can enforce budgets. Each model price has its own currency. Formal never converts between currencies, so spend in each currency is totalled separately.

Steps

1. Set Token Prices

Open Token Pricing in the Control Plane. The author made the model; the provider serves it. For example, Anthropic authors Claude, while Anthropic and Cursor can both provide access to it.
  • Click Add model price and pick the model. Known models fill in their Author.
  • Leave the provider as All providers to set the author’s default price, used on every provider.
  • To price a provider differently, such as Anthropic models through Cursor, add a price for that provider. It replaces the author’s default for that provider.
  • Pick the Currency the prices are in. It defaults to USD, and known models fill in their USD list prices.
  • Add aliases for names the model is requested under, such as opus-4.1 in Cursor.
Formal matches a model price when the requested model contains its name or an alias. The longest match wins. Any price for the request’s provider wins over the author’s defaults, even a shorter match. Formal has no built-in price list. Seen in logs without a model price lists models requested in the last 30 days that no model price matches. Click Set price to price one. Changing a model’s currency doesn’t touch earlier logs. They keep the cost and currency they were recorded with. Verify: send a request, then open its log. The LLM section shows cost and currency.

2. Add Advanced Prices

Expand Advanced pricing in the price dialog. Each empty field falls back to the base price.

3. Enforce Budgets

Request rules read spend in input.user.spend. See Spend object for details. Each window has cost, a map from currency code to amount, and token_count. For example, input.user.spend.today.cost.USD is today’s spend in USD. A currency is absent until the user spends in it, so read it with object.get. token_count also counts unpriced models. Spend refreshes every few minutes, so a burst of requests can exceed a budget slightly. The following policy blocks a user’s requests after $50 in a day or $500 in a month of USD-priced models:
To cap tokens instead, compare token_count, for example input.user.spend.this_week.token_count >= 5000000. Verify: lower a budget below your own spend, send a request, and confirm the block appears in logs.

4. Block Unpriced Models

priced is false when no price matches the request. price_source is provider for a provider’s price, author for an author’s default, or none. The following policy blocks models without a model price, so new models need a price before use:

Troubleshooting

Cause: neither a price for the request’s provider nor a default for the model’s author matches the request. Fix: price the model from Seen in logs without a model price.
Cause: a provider’s price replaces the author’s default for that provider, including cache and reasoning prices. Fix: set every price you need on the provider’s price, or delete it to use the default.
Cause: the policy reads spend in the response rule, or the request has no Formal user. Fix: read input.user.spend in the request rule.

Next Steps

AI Usage

See which models and clients people use

Policy Evaluation

Every field LLM policies can read