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
| Field | Type | |
|---|---|---|
customer_id | string, 1 to 200 characters | Required. See Customer IDs. |
provider | string | Required. openai, anthropic, google and so on. |
model | string | Required. The model that ran. |
input_tokens | integer | The whole prompt, cache reads and writes included. |
output_tokens | integer | |
cached_input_tokens | integer | Cache reads. |
cache_write_input_tokens | integer | Anthropic 5-minute cache writes. |
cache_write_1h_input_tokens | integer | Anthropic 1-hour cache writes. |
feature | string, up to 100 characters | Shows up as cost by feature. |
occurred_at | ISO 8601 with offset | When the call happened. Up to 7 days back. |
idempotency_key | string, up to 200 characters | A 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
429and5xxwith backoff, and send anidempotency_keyso a retry never double counts. - A
429carriesretry-afterandx-ratelimit-*headers. See Limits.
Every other endpoint is in the API reference.