The Stateless Founder

Build Your Own LLM Cost Meter Before the Next Provider Change


Listen Later

Build Your Own LLM Cost Meter Before the Next Provider Change
The Problem: Fragmented Cost Visibility

Provider dashboards only show you one slice of your AI spend. When you're calling OpenAI, Anthropic, and Gemini, you have three separate billing views that don't talk to each other. You can't see total cost per customer, per job, or which workflow is eating your margins.

The Solution: A Vendor-Agnostic Data Layer

Every API call writes one row to one table, same format, regardless of provider. The schema is simpler than you think: 19 fields that capture everything you need for cost attribution, audit compliance, and budget enforcement.

The 19-Field Schema

Core Fields:

  • event_id (UUID)
  • timestamp (UTC)
  • actor_type (user/agent/human_reviewer)
  • provider (normalized: "openai", "anthropic", "google")
  • model (normalized: "gpt-5.4-mini")
  • region
  • Cost Fields:

    • input_tokens
    • output_tokens
    • latency_ms
    • cost_usd
    • Attribution Fields:

      • job_id
      • customer_id
      • Audit Fields (EU AI Act Ready):

        • pii_flag
        • review_required
        • reviewer_id
        • decision (approved/rejected/edited)
        • Quality Fields:

          • eval_score
          • confidence
          • error_code
          • Three Implementation Paths
            Path 1: Spreadsheet First (Under 1 Hour)
            • Google Sheets with Apps Script webhook
            • Looker Studio dashboard
            • Weekly email digest
            • Perfect for solo builders
            • Path 2: Open Source + Data Ownership
              • Langfuse for LLM observability
              • Export to Parquet files
              • Query with DuckDB
              • 30-day hot, 180-day warm retention
              • Path 3: Lightweight SaaS
                • PostHog for event capture
                • Metronome for usage meters
                • Built-in alerting
                • Fastest path if you're already in the ecosystem
                • Spend Caps and Degraded Mode

                  Set two numbers:

                  • Daily cap in dollars
                  • Rolling 7-day cap
                  • When caps trip, don't just stop. Degrade gracefully:

                    1. Queue non-urgent requests
                    2. Route to cheaper models automatically
                    3. Flag for human review if full capability needed
                    4. EU AI Act Compliance

                      The Act becomes generally applicable August 2, 2026. The audit fields in this schema create the evidence trail you need:

                      • Log which calls touched PII
                      • Track human review decisions
                      • Maintain 6-month retention minimum
                      • Resources

                        Indie LLM Cost Meter Starter - Complete template with:

                        • CSV schema and Google Sheets setup
                        • Apps Script webhook code
                        • DuckDB SQL queries
                        • Slack alert recipes
                        • Looker Studio dashboard template
                        • Key Pricing References (May 2026)
                          • GPT-5.5: $5/1M input tokens, $30/1M output tokens
                          • All providers enforce rate limits via 429 responses
                          • Normalize provider names at ingestion to avoid SQL grouping errors
                          • Action Item

                            Add the schema to your next LLM call. Log one row. Once you see that first row land, you'll never go back to checking billing dashboards manually.

                            ...more
                            View all episodesView all episodes
                            Download on the App Store

                            The Stateless FounderBy Santi, Kira