LancelotDocs
Customer IDs

Connect revenue

Customer IDs

One ID joins a customer's revenue to their AI cost. Get this right and everything else follows.

What to send

Send the same ID with every AI call that your billing system stores for that customer. Use a stable internal ID, such as your user or account ID. Avoid IDs that change, like session IDs.

Billing systemPut your ID here
Stripemetadata.customer_id (or metadata.user_id) on the Stripe customer. The Stripe customer ID (cus_...) also works.
RevenueCatThe App User ID

If you bill accounts rather than people, send the account ID, so every seat on a team adds up to one customer.

Email as a fallback

If no ID matches, Lancelot matches Stripe customers by email, but only when that email belongs to exactly one customer on each side. It works, but an ID is more reliable.

Where the SDK finds the ID

  • The customerId you pass when wrapping the client (customer_id in Python).
  • If you already set user on OpenAI requests, or metadata.user_id on Anthropic requests, the SDK uses that, and you can skip customerId.

Gateways have their own fields: see OpenRouter and Helicone.

Calls without a customer

Usage without a customer ID can't be counted for anyone, so it never shows up in a margin. Imports report how many calls arrived without one.

Erasing a customer

When a customer deletes their account with you, call DELETE /api/v1/customers/{id}. Lancelot replaces their ID, email and name with a pseudonym and keeps the costs and revenue, so your totals don't change.