XuanShu API

How is Token usage calculated?

Token usage is generally recorded across input, cache, output, or other metered fields; the Usage view and billing record are authoritative.

Last verified:

How is Token usage calculated?

Token usage is generally recorded across input, cache, output, or other metered fields; the Usage view and billing record are authoritative.

Steps

  1. Save the request ID, model, and time.
  2. Read the response usage fields and query GET /v1/usage.
  3. Reconcile them with the model multiplier and account billing rules.

Limits and exceptions

Usage fields differ by protocol and model; a local tokenizer estimate does not replace server-side billing.