Skip to main content
Limitry is a metering layer that collects usage, enforces limits, and feeds data into subscription billing systems like Stripe or Chargebee. This guide covers the pricing scenarios you can implement.

Core Capabilities

CapabilityImplementation
Event CollectionHigh-volume ingestion with batch support, idempotency, backdating
Aggregationssum, count, max, latest on any numeric field
Periodshour, day, week, month, annual, all_time
Dimensional FilteringFilter by any dimension (model, team, user, environment)
Timezone-Aware BillingCustomer-specific billing cycle anchors with timezone support
Prepaid CreditsBalance wallets with ledger transactions
AlertsPercentage-based thresholds with webhook delivery

Supported Pricing Models

Pure Usage-Based

Per-token, per-API-call, or per-request pricing where customers pay exactly for what they use. Events carry values (e.g., { tokens: 500, cost_cents: 2 }) that meters aggregate over billing periods.
# Track LLM usage
limitry.events.record(
    customer_id="cust_123",
    event_type="llm_call",
    values={"tokens": 1500, "cost_cents": 3},
    dimensions={"model": "gpt-4"}
)

Metered Subscription (Quota + Overage)

Monthly limits that reset on the billing cycle, with alerts and enforcement.
  • Set limits that reset monthly/annually
  • Alert at 80% usage
  • Enforce at 100% or allow overage
  • Export usage to billing system for invoicing
# Create a monthly limit
limitry.limits.create(
    customer_id="cust_123",
    meter_id="api_calls",
    limit_limit_limit_value=10000,
    period="month"
)

# Check before allowing action
result = limitry.limits.check(customer_id="cust_123")
if result.allowed:
    # proceed

Tiered Plans

Different limits per customer based on their subscription tier.
  • Project-wide limits serve as defaults
  • Customer-specific limits for upgrades/enterprise
  • Store tier info in customer.metadata for sync with billing
# Free tier (project-wide default)
limitry.limits.create(
    meter_id="api_calls",
    limit_limit_value=1000,
    period="month"
)

# Pro tier (customer-specific override)
limitry.limits.create(
    customer_id="cust_123",
    meter_id="api_calls",
    limit_limit_value=50000,
    period="month"
)

Dimensional Pricing

Different rates or limits based on dimensions like model, team, or environment.
# Meter only GPT-4 calls
limitry.meters.create(
    name="gpt4_tokens",
    aggregation="sum",
    field="values.tokens",
    event_filter={
        "event_type": "llm_call",
        "dimensions": {"model": "gpt-4"}
    }
)

# Limit by team
limitry.limits.create(
    customer_id="cust_123",
    meter_id="api_calls",
    limit_value=5000,
    period="month",
    dimension_filters={"team_id": "engineering"}
)

Resource-Based (Seats, Storage)

For non-resetting resources like storage or seat counts.
AggregationUse Case
latestCurrent storage bytes, active seats
maxPeak concurrent users
all_time periodResources that don’t reset
# Track storage (latest value wins)
limitry.meters.create(
    name="storage_bytes",
    aggregation="latest",
    field="values.bytes"
)

# Limit that never resets
limitry.limits.create(
    customer_id="cust_123",
    meter_id="storage_bytes",
    limit_value=10737418240,  # 10GB
    period="all_time"
)

Prepaid Credits / Drawdown

Credit wallets for pay-as-you-go with balance management.
# Create a credit balance
balance = limitry.balances.create(
    customer_id="cust_123",
    name="api_credits",
    unit="cents",
    initial_balance=5000  # $50.00
)

# Check before allowing
check = limitry.balances.check_sufficiency(
    customer_id="cust_123",
    name="api_credits",
    amount=10
)
if check.sufficient:
    # proceed with the action, then debit
    limitry.balances.debit(
        customer_id="cust_123",
        name="api_credits",
        amount=3,
        description="GPT-4 API call"
    )

Free Tier with Hard/Soft Limits

Project-wide limits that apply to all customers, with configurable enforcement.
# Project-wide limit (applies to everyone)
limitry.limits.create(
    meter_id="api_calls",
    limit_value=100,
    period="day",
    alert_thresholds=[80, 100]  # Alert at 80%, enforce at 100%
)

Integration with Billing Systems

Limitry handles metering while your billing system (Stripe, Chargebee) handles subscriptions and payments.
┌─────────────────┐      ┌─────────────────┐      ┌─────────────────┐
│  Your App       │      │  Limitry        │      │  Stripe         │
│                 │      │                 │      │                 │
│  1. API call ───┼──────▶  2. Record event│      │                 │
│                 │      │  3. Check limits│      │                 │
│  ◀──────────────┼──────┤  4. Allow/deny  │      │                 │
│                 │      │                 │      │                 │
│                 │      │  5. Webhook ────┼──────▶  6. Update meter│
│                 │      │     (threshold) │      │                 │
│                 │      │                 │      │                 │
│                 │      │  7. Query usage ◀──────┤  8. Invoice     │
└─────────────────┘      └─────────────────┘      └─────────────────┘

What You Build on Top

  1. Webhook handler - Sync usage to Stripe metered billing components
  2. End-of-period job - Report usage totals at billing cycle end
  3. Payment webhook - Top up balances on successful Stripe payments

Customer Metadata for Sync

Store billing system IDs in customer metadata:
limitry.customers.create(
    external_id="cust_123",
    metadata={
        "stripe_customer_id": "cus_xxx",
        "stripe_subscription_id": "sub_xxx",
        "plan": "pro"
    }
)

Billing Cycle Flexibility

The billing_cycle_start field enables flexible billing periods:
ScenarioConfiguration
Mid-month startsCustomer signs up Jan 15, bills Jan 15 → Feb 15
Anniversary billingAnnual plans reset on signup anniversary
Timezone alignmentMidnight resets in customer’s local time
limitry.customers.create(
    external_id="cust_123",
    billing_cycle_start="2026-01-15",  # Bills on 15th of each month
    timezone="America/New_York"
)

What Limitry Does NOT Handle

Not SupportedUse Instead
Subscription lifecycleStripe/Chargebee
Payment processingStripe/Chargebee
Invoice generationStripe/Chargebee
Tax calculationStripe Tax / Avalara
Dunning/retry logicStripe/Chargebee

Best Use Cases

  1. AI/LLM metering - Token counting, cost tracking, model-specific limits
  2. API platforms - Request quotas, rate limits by tier
  3. Multi-tenant SaaS - Per-workspace/team limits with dimensional filtering
  4. Hybrid pricing - Base subscription + usage overage
  5. Fair-use enforcement - Soft alerts at 80%, hard cutoff at 100%