plaingateway
Features

Usage accounting

See what each request cost and when the wallet is charged.

Each successful completion reports its charge in USD three ways:

Where When
usage.cost in the body In the answer; on a stream, in the final usage chunk.
X-PG-Cost-USD header With a non-streamed answer. On a stream, read usage.cost in the final usage chunk.
GET /generation Shortly after the request ends.

The charge is the token counts the host reported, times our price per token. An error answered before the host produced output costs nothing. A finished host response that the gateway could not translate can still be charged.

When the wallet changes

  1. Before a request starts, the gateway reserves its largest possible cost from the balance, or an eighth of what is left with a lower answer limit when funds are short (Errors).
  2. When it ends, the real cost replaces the reserve and lowers your spendable balance at once.
  3. Every 5 minutes, billing writes each closed hour's total to the wallet ledger as one usage row. A later correction to an hour is written as an adjustment row; an hour whose usage disappears is credited back.

Open Logs in a workspace to see its requests and their cost. Logs keeps requests for seven days.