> ## Documentation Index
> Fetch the complete documentation index at: https://docs.fluxrate.co/llms.txt
> Use this file to discover all available pages before exploring further.

# Usage-based Pricing

> Charge customers based on what they actually consume — the pay-as-you-go model.

Usage-based pricing means customers pay only for what they consume. Fluxrate meters their usage in real time and bills the exact amount at the end of each billing period.

## When to Use Usage-based Pricing

* Your product delivers variable value (e.g., API calls, compute, AI tokens)
* You want to lower the barrier to entry (no monthly commitment)
* Your customers have highly variable usage patterns

## Creating a Usage Plan

```bash theme={null}
curl -X POST https://api.fluxrate.co/api/v1/plans \
  -H "Content-Type: application/json" \
  -H "Cookie: access_token=<token>" \
  -d '{
    "name": "Pay-as-you-go",
    "lookup_id": "payg",
    "type": "USAGE",
    "billing_interval": "month",
    "currency": "USD"
  }'
```

## Adding a Usage Charge

Link the charge to a meter using `meter_id`:

```bash theme={null}
curl -X POST https://api.fluxrate.co/api/v1/plans/<plan_id>/charges \
  -H "Content-Type: application/json" \
  -H "Cookie: access_token=<token>" \
  -d '{
    "type": "USAGE",
    "meter_id": "<meter_id>",
    "unit_price": 0.001,
    "display_name": "API calls ($0.001 each)"
  }'
```

## Tiered Pricing

Offer volume discounts with tiered pricing — lower per-unit prices at higher volumes:

```
0–1,000 calls    → $0.002/call
1,001–10,000     → $0.001/call
10,001+          → $0.0005/call
```

<Note>
  Tiered pricing configuration is available via the `usage_pricing_rules` on the meter.
</Note>

## How Usage is Calculated

At invoice generation time, Fluxrate:

1. Queries all `UsageEvent` records for the meter in the billing period
2. Applies the aggregation type (SUM, MAX, etc.)
3. Multiplies the aggregated value by the unit price
4. Creates an invoice line item with the result

## Free Tier / Included Units

You can combine a usage charge with a feature limit to give customers an included allowance:

```
Plan: Pay-as-you-go
├── Feature: API Calls → 1,000 calls/month (hard limit at no charge)
└── Charge: API calls → $0.001/call (billed above 1,000)
```

<Tip>
  Use soft limits on features to allow usage above the free tier while still billing only for the overage. This requires custom logic in your application to differentiate free vs. paid usage.
</Tip>

## Example Invoice

```
Invoice: INV-2025-0042
Period: Jan 1 – Jan 31, 2025

Line Items:
  API Calls (82,450 calls × $0.001)          $82.45
  ─────────────────────────────────────────────────
  Subtotal                                    $82.45
  Tax (0%)                                    $0.00
  Total                                       $82.45
```
