This guide walks through a full Paid integration using a real-world example: an AI chatbot where customers subscribe to monthly plans, receive Chat Credits, and consume them with every message.
By the end you will have signals, AI cost tracking, delivered value, balance enforcement, and checkout working together.
Your product is an AI chatbot. It offers three monthly plans, each granting a different number of Chat Credits. Every chat message consumes 1 credit.
Set up the credit currency and product in the Paid dashboard.
Chat Credits with the key chat_credits.ChatBot with external ID chatbot.chat_message, credit currency Chat Credits, and credit cost 1. Add a credit benefit to each plan that grants the monthly allowance shown in the table above.You can also create products via the API or the CLI.
A signal is a billable event. Send one every time a customer sends a chat message. Because the product’s pricing rule matches on the event name chat_message, Paid automatically deducts 1 Chat Credit per signal.
The data field is optional. Include any metadata you want to see in the dashboard or use in delivered value calculations later.
Cost traces capture what each AI call costs you. Initialize autoinstrumentation once at startup, then wrap your AI calls in a tracing context. Paid records the provider, model, token counts, and cost automatically.
Pass the library names you use ("openai", "anthropic"), or call with no arguments to instrument all supported libraries.
Cost-attributed signals combine steps 2 and 3. Send the signal inside a tracing context and Paid links the billable event to the AI costs captured in the same trace. This gives you per-event margin visibility.
The customer and product are inherited from the tracing context, so you do not need to pass them again in the signal.
Add data fields to your signals that describe the value delivered to the customer. Paid uses these to calculate metrics like time saved or money saved, which appear on value receipts and in the customer portal.
Configure value types in Signals > Signal values to tell Paid how to calculate delivered value from your signal data.
Duration fields need a value and a _unit suffix (seconds, minutes, hours, or days). Monetary fields are always in cents. See Delivered value for the full list of parameter types and binding modes.
Before processing a message, check whether the customer has credits remaining. This lets you show upgrade prompts or block usage when the balance hits zero.
Create a checkout session when a customer wants to subscribe. Paid handles payment collection, plan selection, customer creation, and credit provisioning in one flow.
The customer picks their plan during checkout. After payment, Paid creates an order and grants that plan’s Chat Credits.
When the customer returns, verify the checkout before granting access: