Skip to main content
AI Token Billing lets you charge customers based on the actual AI model tokens they consume. Commet maintains a catalog of 180+ AI model prices, calculates the cost per request, applies your margin, and deducts from the customer’s balance. Only available for plans using the Balance consumption model.

How it works

  1. Your app calls an AI model (GPT-4o, Claude, Gemini, etc.)
  2. You report the tokens consumed to Commet
  3. Commet looks up the model’s token price, applies your margin, and deducts from the customer’s balance
  4. At the end of the billing period, any overdraft is invoiced as overage

Setup

1. Create a feature

Go to Features, create a metered feature (e.g., name: “AI Chat”, code: ai_chat).

2. Add to a balance plan with AI Model pricing

Go to Plans, open a plan with Balance consumption model, and add the feature. Select AI Model as the pricing mode and set your margin percentage.

3. Track usage

Pass the model, inputTokens, and outputTokens when tracking. Commet handles the rest.

Track AI tokens with the SDK

Use the same track() method in every SDK. When you pass model, Commet switches to AI token pricing.
For models with prompt caching, include cache tokens for accurate billing:
Cache read tokens are significantly cheaper than regular input tokens. Commet prices each token type separately so customers pay fair rates.

Automatic tracking with @commet/ai-sdk

If you use the Vercel AI SDK (Node.js only), install @commet/ai-sdk to track tokens automatically.
Wrap your model with tracked(). Every generateText and streamText call is tracked without extra code.
Works with any AI SDK provider: OpenAI, Anthropic, Google, and any model available through the Vercel AI Gateway.

Parameters

Model identifier formats

Commet accepts model identifiers in two formats:

Cost calculation

For each request, Commet calculates:

AI model catalog

Commet maintains a catalog of 180+ AI models with up-to-date token prices, synchronized daily from the Vercel AI Gateway. The catalog includes input, output, cache read, and cache write prices for each model. Supported providers include OpenAI, Anthropic, Google, Meta, Mistral, Cohere, and more.

AI Costs dashboard

View all AI token costs in the dashboard under AI Costs. Each entry shows the model used, token breakdown, cost calculation, margin applied, and total charged.