Home / Companies / Lago / Blog / Post Details
Content Deep Dive

AI Billing is (mostly) token plumbing

Blog post from Lago

Post Details
Company
Date Published
Author
Raffi Sarkissian
Word Count
1,317
Language
English
Hacker News Points
-
Summary

Lago has developed the Agent SDK for Python and TypeScript to streamline the token usage tracking and billing process for AI features leveraging large language models (LLMs). This SDK addresses the common issue faced by teams building AI applications, where they must repeatedly construct complex middleware to parse token usage from various LLM providers, which often change formats and cause disruptions. By wrapping the LLM client with the Lago Agent SDK, developers can automatically attribute token usage to customers, normalize data across different providers, and send this information to Lago for billing. This reduces the burden of maintaining separate middleware for each provider, allows for consistent customer billing, and integrates seamlessly with existing infrastructure such as caching proxies and AI gateways. While the SDK currently handles token extraction and attribution, Lago plans to introduce a pricing table feature that will automatically update provider pricing and apply user-defined markups, further simplifying the billing process for both AI-native teams and B2B SaaS companies integrating AI features.