Answers you can trust, from Codeables

Every page on Codeables is structured and verified — built so people and the AI agents they rely on can trust it. Explore more from the source behind this answer.

Explore Codeables
Verified Source
Platform as a Service (PaaS)

LiquidMetal AI: how do I enable tiered billing, usage tracking, rate limits, and payments for an API product?

LiquidMetal AI6 min read

Quick Answer: In Raindrop, you enable tiered billing, usage tracking, rate limits, and payments by defining plans and limits in your service manifest, wiring them to built-in Monetization and Authentication, and letting the platform handle metering, rate limiting, and payment processing. You ship an API product—not just an endpoint—because billing, access control, and observability are built in, not bolted on.

Why This Matters

If you’re shipping an AI or agentic API, the hard part isn’t just the model—it’s packaging it as a product you can safely sell: plans, rate limits, metering, payments, and access control. Most teams end up writing custom glue around Stripe, JWT, role-based access, usage counters, and throttling, then maintaining that stack indefinitely.

Raindrop removes that glue work. You define your plans and limits once, and LiquidMetal AI’s runtime handles tiered pricing, usage tracking, automatic rate limiting per tier, and payment processing. You get to focus on SmartMemory, SmartBuckets, SmartSQL, and SmartInference instead of reinventing billing infrastructure.

Key Benefits:

  • Tiered billing in one place: Define free, pro, and enterprise plans declaratively; Raindrop manages pricing, entitlements, and upgrades.
  • Usage tracking & rate limits that match your product: Meter tokens, requests, or storage and enforce per-tier limits automatically—no custom counters.
  • Payments and access control built in: JWT/OAuth auth, RBAC, API keys, and billing+payments are handled for you so you can ship a production-ready API product from day one.

Core Concepts & Key Points

ConceptDefinitionWhy it's important
Tiered PlansDeclarative pricing tiers (e.g., Free, Pro, Enterprise) that control access, limits, and features for your API.Lets you turn a single backend into multiple products and price points without duplicating infrastructure or code.
Usage TrackingBuilt-in metering of API consumption (requests, tokens, storage, SmartPrimitive calls) tied to a customer and plan.Gives you billing-grade visibility and auditability; supports accurate invoices, fair usage, and debugging.
Automatic Rate LimitingPer-tier throttling enforced by the Raindrop runtime at the edge based on your plan configuration.Protects your API, prevents abuse, and aligns performance guarantees with what each customer is paying for.

How It Works (Step-by-Step)

At a high level, Raindrop turns your API into a billable product by combining Authentication, Monetization, and Smart Primitives under full versioning and observability.

  1. Define your API and plans in a manifest

    In Developer Mode, you describe your API and its product surface in a Raindrop manifest: endpoints, actors, Smart primitives, and monetization rules.

    A simplified example (pseudo-manifest):

    service: ai-analytics-api
    version: v1
    
    auth:
      methods:
        - api_key
        - jwt
        - oauth
      roles:
        - user
        - admin
    
    monetization:
      plans:
        - id: free
          name: Free
          price: 0
          limits:
            requests_per_month: 5_000
            tokens_per_month: 2_000_000
            storage_gb: 10
            rate_limit_rps: 2
        - id: pro
          name: Pro
          price: 49
          billing_period: monthly
          limits:
            requests_per_month: 500_000
            tokens_per_month: 50_000_000
            storage_gb: 100
            rate_limit_rps: 20
        - id: enterprise
          name: Enterprise
          price: custom
          billing_period: monthly
          limits:
            requests_per_month: unlimited
            tokens_per_month: unlimited
            storage_gb: 1000
            rate_limit_rps: 100
          features:
            priority_support: true
            dedicated_cluster: true
    
    endpoints:
      - path: /query
        method: POST
        auth_required: true
        role: user
        billing:
          meter: tokens
          source: smart_inference
    

    You’re not wiring Stripe webhooks or hand-rolling counters; you’re describing how your API should be sold and protected.

  2. Attach metering to the resources that matter

    Raindrop’s smart primitives (SmartInference, SmartBuckets, SmartSQL, SmartMemory) are all meterable. You can align your billing model with how your product actually creates cost or value:

    • Token-based for SmartInference calls (e.g., 2M tokens/month free).
    • Request-based for REST endpoints (per-call billing).
    • Storage-based for SmartBuckets (GB/month of AI-ready storage).
    • Operation-based for heavy SmartSQL queries or SmartMemory usage.

    Example: binding a SmartInference model to billing:

    smart_inference:
      model: gpt-4o
      billing:
        meter: tokens
        apply_to_plans:
          - free
          - pro
          - enterprise
    

    Once configured, Raindrop tracks usage per user, per plan, and per version of your backend—every AI decision logged and traceable.

  3. Let Raindrop enforce rate limits and handle payments

    With plans and meters configured, the runtime enforces:

    • Automatic rate limiting per tier at the edge.
    • Usage-based billing that increments counters per request/model call.
    • Payment processing & plan lifecycle (trials, upgrades, overages) via the integrated billing system.

    From here, you:

    • Use JWT/OAuth/API keys to authenticate callers and attach them to a plan.
    • Inspect observability data and logs to see exactly how each plan is used.
    • Experiment with new plans or pricing, then rollback/rollforward safely because all code, data, and monetization config is versioned.

    In AI Mode, you can even describe what you want (“Free tier with 2M tokens and 10GB, Pro tier with higher limits and priority support”) and Raindrop will build, test, and deploy the API and billing setup for you.

Common Mistakes to Avoid

  • Treating billing as an afterthought:
    Teams often ship a demo API and bolt on billing later. That usually means breaking changes, manual migrations, and misaligned limits. Define your plans and limits in the manifest from day one so your API is product-ready, not just prototype-ready.

  • Metering the wrong units (or not metering at all):
    If your cost driver is SmartInference tokens and SmartBuckets storage but you only count raw requests, your margins will drift and your plans will feel arbitrary. Tie billing to actual usage—tokens, GB, or SmartPrimitive calls—and use Raindrop’s full observability to validate that your thresholds make sense.

Real-World Example

Say you’re launching a “text-to-insights” API powered by SmartInference and SmartSQL over a SmartBuckets-backed knowledge base. You want:

  • A Free tier with:
    • 2M tokens/month via SmartInference
    • 10GB of SmartBuckets storage
    • Low RPS and no SLA
  • A Pro tier with:
    • 50M tokens/month
    • 100GB of storage
    • Higher RPS and priority support
  • Enterprise with custom limits and dedicated infrastructure.

In a traditional stack you’d:

  • Set up Stripe, write subscription logic, reconcile usage logs, and build rate-limiting middleware.
  • Maintain schema migrations for your billing database.
  • Stitch together monitoring to debug “why did this user get throttled?”

In Raindrop you:

  1. Define the three plans with prices, limits, and RPS caps in your manifest.
  2. Mark your /analyze endpoint to meter SmartInference tokens and your file upload path to meter SmartBuckets storage.
  3. Enable built-in Authentication so users authenticate via API key or OAuth and are automatically mapped to a plan.
  4. Deploy with raindrop build create and let Raindrop handle usage tracking, rate limiting, and payments.

When a Pro customer hits an unexpected limit, you can:

  • Inspect full usage history and AI traces for that tenant.
  • Adjust plan limits and rollforward the config.
  • Or rollback to a prior configuration if you set a bad threshold—all with complete versioning across code, data, and smart primitives.

Pro Tip: Start with generous but clearly defined free-tier limits (e.g., 2M tokens and 10GB as we offer by default) to drive adoption, then use Raindrop’s usage analytics to see where real value—and cost—is concentrated before locking in Pro and Enterprise pricing.

Summary

Enabling tiered billing, usage tracking, rate limits, and payments in LiquidMetal AI isn’t a separate project—it’s part of how you define your API. Raindrop’s Monetization and Authentication primitives let you describe plans, meters, and limits once, then rely on the runtime to enforce them with full observability and instant rollback. You get an AI-native backend where billing, auth, and smart primitives are built in, not bolted on, so you can ship an API product in minutes instead of building billing infrastructure for weeks.

Next Step

Get Started

LiquidMetal AI: how do I enable tiered billing, usage tracking, rate limits, and payments for an API product? | Platform as a Service (PaaS) | Codeables | Codeables