
AI
Agent SDK: bill the dollar cost of LLM calls, margin built in
Anh-Tho Chuong • 1 min read
Jul 21
/1 min read
Reselling LLM access used to mean building a pricing service.
Your app knew how many tokens a customer used. Turning that usage into a dollar amount was your problem: fetch provider price lists, keep them current, calculate every call, apply your margin, and handle missing prices without losing usage.
That pricing layer is now built into the Lago Agent SDK.
The Agent SDK already turns LLM token usage into billing events. Switch on price mode and it also prices each call.
The SDK looks up the model price, calculates the dollar cost from the token usage, applies your markup, and sends Lago one llm_cost event. That event is ready to bill through a dynamic charge.
Set markup: 1.2, for example, and the customer pays your cost plus 20%.
Your LLM costs stay centralized in Lago. You decide what to resell them for.
Prices come from Lago-maintained public price lists:
The SDK refreshes prices in the background. You do not need provider API keys or a price file of your own.
A new model or a cold cache should not make usage disappear.
If the SDK cannot find a price, it falls back to the normal token-count events and calls your error handler. The usage still reaches Lago, and your team gets a visible signal to investigate.
Price mode is opt-in. Token mode remains the default, so existing integrations do not change until you enable it.
Price mode is available in the open-source Python SDK and JavaScript / TypeScript SDK.