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 system | Put your ID here |
|---|---|
| Stripe | metadata.customer_id (or metadata.user_id) on the Stripe customer. The Stripe customer ID (cus_...) also works. |
| RevenueCat | The 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
customerIdyou pass when wrapping the client (customer_idin Python). - If you already set
useron OpenAI requests, ormetadata.user_idon Anthropic requests, the SDK uses that, and you can skipcustomerId.
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.