This document explains how the platform tracks and converts AI service costs into platform credits.
1 Platform Credit = $0.01 USD
All AI service costs are converted to platform credits using the formula: Platform Credits = USD Cost × 100.
Example: A $0.15 USD API call = 15 platform credits
voyage-3.5 (1024D) — sole production text embeddertext-embedding-3-small — legacy CI changelog workflow onlyai_usage_logs TableTracks all AI API calls with detailed cost breakdown. The table stores the following fields: a UUID primary key, user_id referencing auth.users, model_name (e.g., "gpt-4o", "claude-3-5-sonnet"), provider (e.g., "openai", "anthropic", "firecrawl"), operation_type (e.g., "chat", "embedding", "scrape"), input_tokens, output_tokens, cached_tokens, total_tokens, firecrawl_credits (Firecrawl-specific), cost_usd (DECIMAL 10,6 — cost in USD), platform_credits (integer — cost in platform credits, i.e., USD × 100), request_metadata (JSONB), response_metadata (JSONB), and created_at timestamp.
For 1,000 input tokens at $2.50/1M and 500 output tokens at $10.00/1M:
For 5 Firecrawl credits at an estimated $0.001 per credit:
To get total platform credits, total USD spend, and API call count per user over the last 30 days, query ai_usage_logs grouped by user_id, summing platform_credits and cost_usd, and filtering by created_at >= NOW() - INTERVAL '30 days'.
To see which models are consuming the most credits over the last 7 days, query ai_usage_logs grouped by model_name and provider, summing total_tokens and platform_credits, ordered by total_credits descending.
All pricing is centralized in app/config/ai_pricing.py:
Decimal for precisionlast_verified date and source URLUsers can purchase credits for any dollar amount ($1–$500). Larger purchases unlock better rates:
| Tier | Spend | Rate | Credits per $1 | Discount |
|---|---|---|---|---|
| Standard | $1–$9.99 | $0.010/credit | 100 | 0% |
| Silver | $10–$44.99 | $0.009/credit | ~111 | 10% |
| Gold | $45–$79.99 | $0.008/credit | 125 | 20% |
| Platinum | $80+ | $0.007/credit | ~143 | 30% |
Pricing logic: src/services/stripe.service.ts → calculateCreditsForAmount()
Stripe setup: A single "Material KAI Credits" product (STRIPE_CREDITS_PRODUCT_ID) is reused for all purchases. Prices are set dynamically at checkout via price_data.