moth docs
Protocol Hold, then settle

Hold, then settle

A call reserves its worst case before the model runs and pays what it used when it ends, so the balance can't go below zero and no call costs more than its hold.

Three states

  1. A call arrivesIts worst case is worked out from the body and max_tokens
  2. HeldThe worst case is reserved, and balance_usd already leaves it out
  3. SettledThe call ended, the real charge is taken and the rest comes back
    or
    ReleasedThe call failed before any output, and the whole hold comes back
Every paid call ends settled or released, and only a settled call is charged.

How big the hold is

  • Input is estimated from the body as Moth rebuilds it, compact and without unknown fields or image data, as its size in bytes divided by three, plus 5,000 tokens for each image, which is more than a real count on purpose.
  • Output is your max_tokens, or 4,096 on /chat/completions when you send none.
  • A web search adds 40,000 input tokens to the hold, since the pages it reads count as input.
  • Models that reason before answering, grok-4.7, deepseek-v4.1-flash and kimi-k3, hold at least 2,048 output tokens however small max_tokens is, and their hidden reasoning is charged as output up to that amount, so a small max_tokens doesn't bring their cost below it.

A worked example

A call to gemini-3.8-flash, priced at $0.375 per million input tokens and $1.875 per million output tokens, sends a body that comes to 1,200 bytes, with max_tokens set to 1,000. The model reports 290 input tokens and 180 output tokens.

StepTokensAmount
Hold for input400, from 1,200 bytes ÷ 3$0.000150
Hold for output1,000$0.001875
Held$0.002025
Charge for input290$0.00010875
Charge for output180$0.0003375
Settled$0.000447, rounded up once to the millionth
Released$0.001578

The reply's moth-charged-micros header reads 447. Prices follow the catalog, so read today's from the models list.

Held $0.002025 for a gemini-3.8-flash call, then settled

Charged $0.000447Released $0.001578
  • Charged, what the call used
  • Released, back to your balance
The worked example as one bar. Hover over or focus a part to see what it covers, and the table above holds every figure.

When a call doesn't finish

  • A call refused before it reaches the model, or failed there with no output, releases its whole hold.
  • If you disconnect after the prompt was sent but before any output, the input is charged and nothing else, and a stream you leave after output began is also charged for the output it had sent.
  • A stream settles once, when it ends, fails or you leave, at the usage seen so far.
  • A reply cut at max_tokens is charged at least max_tokens of output.
  • A hold left open by a restart is released when the server starts, and any hold older than two hours is released within five minutes.

Media jobs

A job holds its unit price times its units, which is n images, the clip's seconds or one song. When it succeeds, images are charged per image delivered and a clip or a song in full. A job that fails, or hasn't finished after an hour, is charged nothing.

Never above the hold. The charge is never more than the hold, whatever the host reports.