<!-- https://leantools.ai/doc/credits · HTML twin of this page; the whole documentation: https://leantools.ai/llms-full.txt -->
# Credits and billing

Getting started

Tools are paid for in credits. A workspace holds a prepaid balance, every call draws it down at a published unit price, and the console shows where each credit went.

## Buckets

A workspace holds three blocks of credits, consumed in this order:

| Bucket | Filled by | Expires |
| --- | --- | --- |
| Trial | Starter credit at sign-up, or a trial package an operator applies | After the package's trial period, or never |
| Subscription | Reloaded every cycle by a subscription package | At the next reload (no rollover) |
| Prepaid | Reloads from the console (card, or invoice above the threshold) and auto-reload | Never |

One credit has a fixed dollar value (`LeanTools.Billing.CreditUsdValue`, shown in the console and returned as `creditUsdValue` by the console APIs). Prices on the public site are that value times the credit rate.

## Meters

Each service exposes one or more meters; the workspace's package defines the credits per unit of every meter, falling back to the service default. A refused or failed call is never charged.

| Service | Meter | Unit | Notes |
| --- | --- | --- | --- |
| Web Search | `request` | per query | Also the native MCP tool `web_search.search` |
| LeanBrowser | `request`, `session_minute` | per HTTP request, per active WebSocket minute |  |
| LeanModel text | `input_tokens`, `output_tokens`, `audio_minute` | per 1,000,000 tokens; per minute of audio transcribed or heard | Priced per tier; a tier the package does not price is `403 tier_not_in_package`. A chat request carrying audio parts adds an `audio_minute` line to its tokens |
| LeanModel image | `image` | per image generated or edited | Priced per tier; billed per image produced |
| LeanModel speech | `tts_character` | per 1,000 characters | Priced per tier |
| LeanModel music | `music_second` | per second of music produced | Priced per tier; the seconds asked for when the model reports no length |
| LeanModel video | `video_second` | per second of video produced | Priced per tier |
| LeanModel avatar | `stream_minute`, `management` | per connected minute; free | Priced per tier; accrued every minute from creation until the stream closes |
| LeanModel realtime audio | `audio_input_tokens`, `audio_output_tokens`, `input_tokens`, `output_tokens`, `cached_input_tokens` | per 1,000,000 tokens, as the model reports them per response | Priced per tier, all five together; committed as the conversation goes, and the socket closes with code 1008 when credits run out |
| Email | `email` | per recipient (to + cc + bcc, at most 50) | Also the native MCP tool `email.send` |
| LeanMachine | `active_minute` | per minute a machine runs | Machines are stopped when credits run out |
| LeanVision | `stream_minute` | priced per stream-hour | Accrued every minute until disposal |
| LeanMemory: warehouse, vectors, events | `storage_gb_month`, `compute_second`, `ingest_gb`, `egress_gb`, `management` | GB-month, per 1,000 s, per GiB, per GiB, free | Attributed by the database named |
| LeanMemory storage | `storage_gb_month` | per GB-month held | No ingress, egress or request charge |
| LeanData | `call`, `row`, `month` | per query, per 1,000 rows, per subscription month | Priced per dataset (qualifier = dataset key) |
| LeanConnect connectors | `call` | per completed action | Priced per connector (qualifier = connector key); refused, failed and timed-out actions cost 0 |

Only measurements and upstream attribution are stored per call (zero data retention): no request or response payload is kept. Per-request rows are archived monthly; aggregates are kept indefinitely.

## Caps, budgets and guardrails

- **Key cap.** A monthly spend cap per API key: `402 key_cap_reached` once reached, reset on the first of the month (UTC).
- **Tool budget.** A monthly credit budget per native tool with "pause at budget": `402 tool_budget_reached`. Without pausing, the budget only drives the warning in the console.
- **Connector guardrails.** Per connector: calls per minute (`429 rate_limited`), calls per day (`429 daily_cap_reached`), the keys allowed to use it, the functions exposed, and whether write actions are held for [approval](https://leantools.ai/doc/connectors#approvals).
- **In-flight reserve.** When several calls of one workspace are in flight and the remaining balance no longer covers roughly one credit per running call, new calls are refused with `402 insufficient_credits` until they finish or the balance grows (`LeanTools.Credits.InFlightReserveCredits`).

## Reloading credits

Owners and Billing members reload from [Settings → Billing & credits](https://leantools.ai/app#/settings/billing):

- **Any amount** between the host's minimum and maximum (`LeanTools.Billing.MinReloadUsd`, `MaxReloadUsd`), paid with a saved card. The quote shows the credits added and the balance after. A retried or double-submitted payment is charged once.
- **Auto-reload.** When the balance falls under a threshold, the default card is charged a fixed amount, up to a monthly limit. The console banner and the low-balance email warn before credits run out.
- **Invoice.** Amounts of `LeanTools.Billing.InvoiceThresholdUsd` or more can be requested as an invoice; credits are granted when the host confirms the bank transfer (an operator marks the order paid in the admin panel).
- **Receipts.** Every paid order has a numbered receipt (HTML) and the credit history exports as CSV.

> The payment provider is pluggable (`LeanTools.Billing.PaymentProvider`). A host running the sandbox provider shows a "sandbox" badge in the console: card numbers ending in `4242` succeed, numbers ending in `0002` are declined, and nothing is charged.

## Account endpoints

 (GET)/api/v1/accountbalances, status, effective package and the rates that apply to the caller

```
{
  "accountGuid": "…", "name": "Acme", "status": "Active", "trialUnlimited": false,
  "packageCode": "SUB-2K", "packageName": "Subscription 2K", "packageMode": "Subscription",
  "available": 2874.25, "trial": 0, "subscription": 2874.25, "prepaid": 0, "overdraft": 0,
  "nextReloadTime": "2026-10-01T00:00:00+00:00", "trialExpiry": null,
  "services": [ { "key": "TextAssistant", "name": "LeanTools Text Gen", "billingMode": "PerRequest",
      "meters": [ { "meterKey": "input_tokens", "unit": "Token", "unitScale": 1000000, "isFree": false, "requiresTierRate": true, "creditPerUnit": null } ],
      "tiers": [ { "id": "leanmodel-flash", "displayName": "LeanModel Flash", "kind": "Text", "catalog": "LeanTools Text Gen", "isDefault": true, "isStandard": true,
                   "operations": [ "chat.completions", "audio.transcriptions" ],
                   "rates": { "input_tokens": { "creditPerUnit": 1.0, "unitScale": 1000000 }, "output_tokens": { "creditPerUnit": 4.0, "unitScale": 1000000 } } } ] } ]
}
```

 (GET)/api/v1/account/usage?from=&to=&groupBy=service|meter|dayrequests and credits for the range (default last 30 days)

 (GET)/api/v1/account/transactionsthe latest 200 credit movements other than usage

 (GET)/api/v1/packagesthe public package catalogue

 (GET)/api/v1/servicesevery service with its meters (no authentication)

 (GET)/api/v1/models/tiers?service=the LeanModel tiers the caller may name in `model`, with catalogue, capabilities, operations and rates; `?service=` narrows to one catalogue

### Usage feedback on responses

Chat completion responses (and the final streaming chunk) carry the standard `usage` object extended with `credits_charged`, `credits_remaining` and `cost_usd`. Image, transcription, music and video responses carry `usage` with `credits_charged` and `cost_usd`; a speech response is the audio itself, so its usage rides in the `X-LeanTools-Usage` header; an avatar stream reports its minutes and credits when it is closed, and realtime audio is billed per `response.done` as the conversation goes. Data, connector and tool calls answer a `usage` block with `credits` and `balance`. MCP results embed the same block in the result text.
