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
- Save the request ID, model, and time.
- Read the response usage fields and query GET /v1/usage.
- 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.