Outcome pricing for a support agent
Resolvio’s agent answers support tickets for e-commerce brands. Customers pay $1.50 for each ticket the agent resolves and $0.25 for each ticket it escalates to a human, plus a $500 monthly platform fee. Resolvio pays a model provider for inference, so it also records what each agent turn cost, and its customers see their tickets and spend inside Resolvio’s app.
This example uses:
- Products
- Meters, including a workflow meter that turns ticket events into one outcome per ticket
- Prices: usage prices per outcome, recurring platform fees and a cost-plus price
- Customers
- Orders and amendments
- Events, with cost lines
- Usage summaries
The calls below show only the request body. Every request also sends the headers described in Request headers: Authorization, Paid-Version, and a Paid-Beta opt-in for the resource you call (products=v1, meters=v1, prices=v1, customers=v1, orders=v1, events=v1 or usage_summaries=v1, plus event_costs=v1 on events that carry cost lines). Writes also send an Idempotency-Key, so a retry never creates a second object; see Idempotency.
Money amounts in this example are in cents. A price’s unitAmount is a decimal string of cents ("150" is $1.50), and amounts returned by Paid, such as an amendment’s moneyEffects, are integer cents.
Setup
Create a product for the agent:
Create a meter that follows each ticket from its first event until it closes. Every event about a ticket carries the same ticket_id, which the meter uses as the workflow identifier. When a ticket closes, the meter classifies it by the first outcome whose conditions all hold and emits one ticket under that outcome. Tickets that match neither outcome, or that get no close event within 7 days, are discarded.
Create a price for each outcome. usage.outcome names the outcome the price charges for. This one is prc_resolved:
The escalated price, prc_escalated, is the same with "name": "Escalated ticket", "outcome": "escalated" and "unitAmount": "25".
The platform fee is a recurring price, invoiced in advance at the start of each month. This one is prc_platform:
Resolvio also offers a Pro tier. Its fee, prc_platform_pro, is the same request with "name": "Platform fee (Pro)" and "unitAmount": "80000".
Signing Acme Retail
Create an order with the two outcome prices and the platform fee. It runs month to month with no endsAt, and invoices are due on receipt:
The order is created as a draft, with the ID ord_acme in this example. Activate it with POST /v1/orders/ord_acme/activate, which takes no body, to start billing.
Every agent turn
Resolvio sends an event for each message on a ticket, each status change, and when the ticket closes. The meter reads payload.ticket_id and payload.status. When an event comes from a model call, Resolvio adds a cost line for the inference it paid for:
The cost line has no amount, so Paid prices it from its model catalog. The returned event carries the priced line, with pricing.source set to paidCatalog, and adds uncachedInputTokens: 3000 so cached tokens are counted once.
When the agent hands a ticket to a human, Resolvio sends a ticket.status_changed event with "status": "escalated". When the ticket is done, it sends ticket.closed with the final status, which closes the workflow and prices the ticket.
Acme Retail’s month
- Usage total: $3,827.50 ($3,675.00 + $152.50). Each ticket is billed once, under its first matching outcome, in the period it closed.
- Invoice total: $4,327.50, the outcomes plus the $500.00 platform fee. The fee is invoiced in advance at the start of the month and the outcomes in arrears at the end.
- Margin: the priced inference lines on Acme’s events come to $612.40 for the month (illustrative), against $4,327.50 billed.
To show Acme its tickets and spend by month, Resolvio lists usage summaries with these query parameters:
Each row has a ticket quantity and spend for one outcome in one month, with status: "provisional" on the month that is still open.
Acme upgrades mid-month
On 16 November, Acme moves to the Pro platform fee ($800 a month). Resolvio previews the amendment, replacing the price on the platform-fee line (ordl_4Tm8Qc, from the order’s lines). expectedVersion is the order’s current version, so the change fails if the order changed in the meantime:
The preview’s moneyEffects show the proration before anything changes. November has 30 days, and 16 to 30 November is 15 days, including the effective day:
To apply it, Resolvio creates the amendment at POST /v1/orders/ord_acme/amendments with the same body plus the preview’s previewToken, so what is applied is exactly what was previewed.
- Usage isn’t touched. The outcome prices stay on the order, so tickets bill the same before and after.
- History is kept. The old platform-fee line stays on the order with
endedByAmendmentset, and December’s invoice charges $800.00 in advance.
Globex: inference passed through at cost plus 20%
Globex runs high volumes and wants a lower outcome rate in exchange for paying for the model calls. Resolvio charges $0.50 per resolved ticket and passes inference through at cost plus 20%, using the cost lines it already sends.
First, a meter that counts agent turns:
Then a costPlus price on that meter, prc_model_usage, which bills the inference cost lines on the metered events multiplied by 1.2:
The volume resolved-ticket price, prc_resolved_volume, is the resolved outcome price from setup with "unitAmount": "50". Globex’s order has three lines: prc_resolved_volume, prc_platform and prc_model_usage. It has no escalated price, so escalated tickets aren’t charged. Its month:
Resolvio’s margin on inference is the $388.05 markup ($2,328.30 − $1,940.25).