Meter AI token usage
Track input tokens, output tokens, and model cost.
Track input tokens, output tokens, and model cost.
AI APIs often need more than request counting. Token and cost meters let billing track the real work done by the upstream model.
input_tokens
output_tokens
dollars
requests
Use requests for basic traffic analytics even when billing is based on tokens
or cost.
Usage is metered by input tokens and output tokens. Token counts are reported by
the model provider after each request. Your usage page may update shortly after
the response is returned.
For AI products, the gateway may estimate usage before forwarding and reconcile actual usage after the upstream responds.
Make sure subscribers understand that final billable usage may depend on the model response.
Send a test request:
curl https://<product-host>/v1/chat \
-H "Authorization: Bearer <subscriber-api-key>" \
-H "Content-Type: application/json" \
-d '{"messages":[{"role":"user","content":"Say hello in one sentence."}]}'
Confirm: