SaaS APIs
Predictable, Per-Call Cost
API calls have a fixed, amortizable compute cost. The size of the JSON payload has a negligible impact on the price.
Billed by the Request
The billable event is the API call itself.
A revenue-first framework that creates a double-entry ledger for every agent operation. Stop building on shallow proxies. Start building on a true system of record for your AI business.
Andreessen Horowitz just declared:
“AI is driving a shift towards outcome-based pricing. Software is becoming labor.”
But where is the infrastructure for outcome-based billing & accounting?
This not a payments problem, but an accounting problem that leads to catastrophic failure. The future is outcome based...but the tools to build it don't exist.
Until now.
Why is monetizing AI agents so difficult? Because the financial models that powered the last decade of SaaS are fundamentally broken in the world of Generative AI.
Predictable, Per-Call Cost
API calls have a fixed, amortizable compute cost. The size of the JSON payload has a negligible impact on the price.
Billed by the Request
The billable event is the API call itself.
Variable, Computational Cost
An agent's cost is directly tied to the “work” it performs. It's a metered, computational resource, not a fixed endpoint.
Billed by the Computation
The billable events are the input tokens, output tokens, the number of thoughts, and every downstream tool call the agent makes.
This creates a massive accounting problem that traditional billing systems cannot solve. Trying to price a variable, multi-step agentic workflow like a simple API call forces you to either guess—and consistently underbill or overcharge your customers—or build a complex, brittle accounting system from scratch.
Simple token counters and API proxies are failing. They see the token count and total bill from your model provider, but they can't tell you the profitability of a single agent run.
StringCost isn't a language-level library; it's a compile-time harness for your framework. We integrate directly into the build and deployment lifecycle. For our first target, Next.js, we use deep framework-level tools like the Vercel Build Output API to package your agents and their instrumentation together, ensuring perfect compatibility and control over the deployment environment.
Our step primitive is the core of this ledger. It forces every discrete computational action to be recorded as a distinct line item with two sides:
The result is a perfect, auditable, real-time P&L for every single agent run. You can finally answer critical business questions: “Which agents are most profitable?”, “Which tools are driving the most cost?”, and “What is the true margin on our AI features?”
StringCost provides a cohesive set of primitives that transforms your agent's logic into a fully instrumented, deployable, and billable asset.
Our Inngest-like developer experience keeps your team shipping. Every `step` wraps logic and turns it into a traceable, auditable, billable event.
// Every step is a line item on a future invoice.
const thought = await step({
name: "Analyze User Intent",
actionType: "llm_call",
unitCost: 0.001
}, ...);
const dbResult = await step({
name: "Query Customer DB",
actionType: "tool_use",
unitCost: 0.005
}, ...);Stop choosing between flexibility and scalability. Leverage Vercel's Build Output API to ship custom runtimes with serverless performance.
// vercel.json — full control of the build.
{
"buildCommand": "node build.js",
"outputDirectory": ".vercel/output",
"framework": null
}// build.js — package tools as optimized functions.
class VercelCustomBuilder {
async build() {
await this.buildMCPFunctions(); // API wrappers
await this.buildAgentFunctions(); // Agent logic
}
}Native Stripe utilities power real-time usage tracking, subscription gating, and invoice automation—tying every agent action straight into revenue.
// lib/framework.ts — automatically track usage.
import { trackUsage } from '@/lib/stringcost/server';
class BillingManager {
async record(event) {
await trackUsage({
userId: this.userId,
featureId: event.actionType,
usage: Math.round(event.cost * 1000) || 1,
});
}
}// middleware.ts — protect premium features.
import { checkEntitlement } from '@/lib/stringcost/server';
export async function middleware(request: NextRequest) {
if (request.nextUrl.pathname.startsWith('/premium-agents')) {
const { hasAccess } = await checkEntitlement({ /* ... */ });
if (!hasAccess) {
return NextResponse.redirect(new URL('/pricing', request.url));
}
}
}Every team gets the visibility and control they need without rebuilding billing infrastructure from scratch.
Go to market with complex, usage-based pricing models in days, not quarters. Experiment with billing per-action, per-thought, or per-tool.
Build any agent imaginable with a Next.js-native DX while the framework handles billing, observability, and compliance-grade audit trails.
Eliminate billing errors with a perfect record of every billable action. Sync usage to Stripe for invoices your customers—and auditors—can trust.
This double-entry approach unlocks any pricing strategy you can imagine.
Assign different costs and prices to different actions. Charge more for premium tools or more powerful models.
// Agent Code await step({ name: "Basic Analysis", actionType: "llm_call", unitCost: 0.001 }, ...); await step({ name: "Premium Data Tool", actionType: "tool_use", unitCost: 0.050 }, ...); // Resulting Ledger // DEBIT: Cost of gpt-4-turbo tokens // CREDIT: $0.0010 revenue // DEBIT: Cost of Premium Data API // CREDIT: $0.0500 revenue
The price of a step can be calculated at runtime. Charge based on execution time, ensuring your margins are always protected.
// Registering a tool with // a dynamic cost function McpRegistry.register( 'dataApi', '...', (metrics) => { // Base fee + time-based markup const timeCost = Math.floor( metrics.durationMs / 100 ) * 0.005; return 0.01 + timeCost; } );
Build ultimate trust with your customers. Since every step captures execution outcome, you can design billing models that only create a revenue entry for successful actions.
// Your billing logic function processBillingEvent(event) { // The COGS (debit) is always // recorded, but the revenue // (credit) is conditional if (event.outcome === 'success') { chargeCustomer( event.userId, event.cost ); } }
Schedule a demo to see how StringCost's double-entry ledger can give you the financial control to ship profitable AI agents with confidence.