Getlago

Jul 21

/

1 min read

Agent SDK: bill the dollar cost of LLM calls, margin built in

Anh-Tho Chuong

Anh-Tho Chuong

Share on

LinkedInX

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.

One cost event per call

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.

No price file to maintain

Prices come from Lago-maintained public price lists:

  • OpenRouter for native OpenAI, Anthropic, Mistral, and Google Gemini models
  • The AWS Bedrock public price list for models called through Bedrock

The SDK refreshes prices in the background. You do not need provider API keys or a price file of your own.

Missing prices do not become missing revenue

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.

Read the documentation · See the changelog


Share on

LinkedInX

More from the blog

Lago solves complex billing.