How it works
- Your app calls an AI model (GPT-4o, Claude, Gemini, etc.)
- You report the tokens consumed to Commet
- Commet looks up the model’s token price, applies your margin, and deducts from the customer’s balance
- 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 themodel, inputTokens, and outputTokens when tracking. Commet handles the rest.
Track AI tokens with the SDK
Use the sametrack() method in every SDK. When you pass model, Commet switches to AI token pricing.
- TypeScript
- Python
- Go
- Java
- PHP
- cURL
- TypeScript
- Python
- Go
- Java
- PHP
- cURL
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.
tracked(). Every generateText and streamText call is tracked without extra code.