Usage Billing on Steroids

Leverage our Event Ingestion Strategies to track any usage with precision

Track any metric with precision

Use our Ingestion Strategies to track any usage with precision.

  • Real-time usage & aggregation
  • Multiple aggregation functions
  • Strategies or manual Event Ingestion
  • Built for scale, precision & accuracy
Usage Billing
import { Ingestion } from "@polar-sh/ingestion";
import { LLMStrategy } from "@polar-sh/ingestion/strategies/LLM";
import { generateText } from "ai";
import { openai } from "@ai-sdk/openai";

const llmIngestion = Ingestion({ accessToken: 'xxx' })
  .strategy(new LLMStrategy(openai("gpt-4o")))
  .ingest("openai-usage");

export async function POST(req: Request) {
  const { prompt }: { prompt: string } = await req.json();

  const model = llmIngestion.client({
    externalCustomerId: "<USER_ID_FROM_YOUR_DATABASE>",
  });

  const { text } = await generateText({
    model,
    system: "You are a helpful assistant.",
    prompt,
  });

  return Response.json({ text });
}

Flexible usage billing

All the tools you need to integrate flexible usage billing into your application

Event Ingestion

Ingest events from your application to track usage.

Customer Meters

Aggregate events into meters to track usage by customer.

Billing

Invoice your customers for their usage on a monthly basis.

Ready to implement usage billing?

Join companies that trust Polar for accurate, scalable usage-based billing.