LancelotDocs
HTTP API

Send usage

HTTP API

Send usage from any language. One endpoint, up to 500 events per request.

curl https://api.lancelot.watch/api/v1/events \
  -H "Authorization: Bearer $LANCELOT_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "events": [{
      "customer_id": "cus_123",
      "provider": "openai",
      "model": "gpt-5-mini",
      "input_tokens": 1200,
      "output_tokens": 300,
      "feature": "search"
    }]
  }'

A successful request returns 202:

{ "accepted": 1, "unpriced_models": [] }

unpriced_models lists any provider/model Lancelot has no price for yet. Those calls are kept with zero cost and recalculated once the price is added.

Event fields

FieldType
customer_idstring, 1 to 200 charactersRequired. See Customer IDs.
providerstringRequired. openai, anthropic, google and so on.
modelstringRequired. The model that ran.
input_tokensintegerThe whole prompt, cache reads and writes included.
output_tokensinteger
cached_input_tokensintegerCache reads.
cache_write_input_tokensintegerAnthropic 5-minute cache writes.
cache_write_1h_input_tokensintegerAnthropic 1-hour cache writes.
featurestring, up to 100 charactersShows up as cost by feature.
occurred_atISO 8601 with offsetWhen the call happened. Up to 7 days back.
idempotency_keystring, up to 200 charactersA repeated key is skipped, so retries are safe.

Token counts default to 0. Unknown fields are ignored. An occurred_at more than 7 days old, or in the future, is replaced with the time Lancelot received the event.

Batching and retries

  • Up to 500 events and 1 MB per request.
  • Retry on 429 and 5xx with backoff, and send an idempotency_key so a retry never double counts.
  • A 429 carries retry-after and x-ratelimit-* headers. See Limits.

Every other endpoint is in the API reference.