Farther ShoreDocs
Go to Farther Shore
Getting startedCore conceptsLaunch checklist
ProductsUpstream routingEnvironmentsDeveloper portals
Billing strategiesPlans and limitsSubscribersAPI keys
Gateway enforcementUsage meteringLimits and creditsGateway sharding
Launch a request-counted product15mAdd monthly included usageAdd subscription plus overageCreate a prepaid credits productMeter AI token usageAdd a custom meterIssue and test an API keyDebug a denied requestUpdate product docsPrepare for launch
TroubleshootingGateway response codesMeter namingPlatform docs publishing
Status
Docs/Cookbook/Meter AI token usage

Meter AI token usage

Track input tokens, output tokens, and model cost.

PreviousCreate a prepaid credits productNextAdd a custom meter

On this page

Recommended metersStepsExample product docsEstimated and actual usageValidation

AI APIs often need more than request counting. Token and cost meters let billing track the real work done by the upstream model.

Recommended meters

input_tokens
output_tokens
dollars
requests

Use requests for basic traffic analytics even when billing is based on tokens or cost.

Steps

  1. Create meters for input tokens and output tokens.
  2. Add a cost meter if you bill or limit by provider cost.
  3. Configure the upstream to return actual usage when possible.
  4. Map upstream usage to Farther Shore meters.
  5. Choose a billing strategy.
  6. Test with small and large prompts.

Example product docs

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.

Estimated and actual usage

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.

Validation

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:

  • the request is allowed
  • actual token usage is captured
  • usage appears on the expected subscriber
  • plan limits use the intended meter