> This page is for version Preview (default).
> For other versions, use one of these documentation indexes:
> - Preview (default): https://docs.preview.paid.ai/preview/llms.txt
> - Current: https://docs.preview.paid.ai/current/llms.txt

> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.preview.paid.ai/llms.txt.
> For AI client integration (Claude Code, Cursor, etc.), connect to the MCP server at https://docs.preview.paid.ai/_mcp/server.

# Chat subscription with credit buckets

> A multi-model chat app sells a flat monthly subscription and meters every message in credits drawn from a 4-hour bucket and a monthly bucket.

Wingtip is a multi-model chat app sold as a self-serve subscription: Base at \$20 a month and Premier at \$200 with 10 times the usage. Every message costs credits that follow Wingtip's inference cost, 1 credit to \$0.001. Credits come from two buckets, spent in order: one that refills every 4 hours, and a monthly one.

This example uses:

* [Credit currencies](../../api-reference/catalog/credit-currencies/create) for the credits
* [Products](../../api-reference/catalog/products/create), [meters](../../api-reference/metering/meters/create) and a [rate card](/core-concepts/introduction-to-pricing), in preview, that prices messages in credits
* [Prices](../../api-reference/catalog/prices/create) whose grants fill the buckets, and [plans](../../api-reference/catalog/plans/create)
* [Customers](../../api-reference/customers/customers/create) and [orders](../../api-reference/billing/orders/create)
* [Credit holds](../../api-reference/credits/credit-holds/create), [events](../../api-reference/metering/events/create) and [credit grants](../../api-reference/credits/credit-grants/list)
* [Amendments](../../api-reference/billing/amendments/create) for an upgrade

> **Note**
>
> The calls omit the headers every request sends: `Authorization`, `Paid-Version`, the `Paid-Beta` opt-in each endpoint requires (such as `credits=v1` for credit endpoints, or `events=v1,event_costs=v1,credits=v1` for an event with costs and a hold), and an `Idempotency-Key` on writes. See [request headers](../../api-reference/introduction#request-headers) and [idempotency](../../api-reference/idempotency).

## The pricing \[#the-pricing]

| Bucket  | Base  | Premier | Refills                                           | Unused credits          |
| ------- | ----- | ------- | ------------------------------------------------- | ----------------------- |
| 4-hour  | 50    | 500     | Every 4 hours from the start of the month's grant | Lost at the next refill |
| Monthly | 2,000 | 20,000  | Each month, with the subscription                 | Lost at renewal         |

Credit rates follow inference costs one to one:

| Usage                            | Small models (`model-small-*`) | Large models (`model-large-*`, and any other model) |
| -------------------------------- | ------------------------------ | --------------------------------------------------- |
| Input, per 1M tokens             | 800 credits                    | 5,000                                               |
| Cached input, per 1M tokens      | 300                            | 300                                                 |
| Output, per 1M tokens            | 4,000                          | 25,000                                              |
| Prompt over 200,000 input tokens | Input and cached input × 2     | Input and cached input × 2                          |
| Web search; attached file        | 10 each; 5 each                | 10 each; 5 each                                     |

## Setup \[#setup]

[Create a credit currency](../../api-reference/catalog/credit-currencies/create) for the credits. With no `conversion`, usage past the balance is recorded as overage but never billed:

**`POST /v1/credit-currencies`**

```json title="POST /v1/credit-currencies"
{
  "key": "wingtip_credits",
  "name": "Wingtip credits",
  "conversion": null
}
```

[Create the product](../../api-reference/catalog/products/create):

**`POST /v1/products`**

```json title="POST /v1/products"
{
  "externalId": "wingtip_chat",
  "name": "Wingtip",
  "displayName": "Wingtip"
}
```

Wingtip sends one `message.completed` event per message, with the model call as an inference cost line. [Create a meter](../../api-reference/metering/meters/create) per token type that reads that line, grouped by model:

**`POST /v1/meters`**

```json title="POST /v1/meters"
{
  "key": "input_tokens",
  "name": "Input tokens",
  "eventNames": ["message.completed"],
  "measure": {
    "type": "events",
    "events": {
      "aggregation": { "type": "sum", "sum": { "path": "cost.inference.uncachedInputTokens" } },
      "unit": "token",
      "groupBy": ["cost.inference.model"]
    }
  }
}
```

Do the same for `cache_read_tokens` (path `cost.inference.cacheReadInputTokens`) and `output_tokens` (path `cost.inference.outputTokens`); Paid derives `uncachedInputTokens`, so cached input is counted once. Two more meters, `web_searches` (unit `search`) and `attachments` (unit `file`), sum `payload.webSearches` and `payload.attachments` the same way.

Set up a rate card, `wingtip_credit_rates`, in the `wingtip_credits` credit currency. The rate card API is in preview; [Introduction to pricing](/core-concepts/introduction-to-pricing) explains how a rate card prices meters. Small models match by prefix. Rates with no match are the fallback, so large models, and any model added later, get large-model rates. A long-context modifier doubles input and cached input on any message over 200,000 input tokens.

| Meter               | Model          | Credits            |
| ------------------- | -------------- | ------------------ |
| `input_tokens`      | `model-small*` | 800 per million    |
| `output_tokens`     | `model-small*` | 4,000 per million  |
| `input_tokens`      | any other      | 5,000 per million  |
| `output_tokens`     | any other      | 25,000 per million |
| `cache_read_tokens` | any            | 300 per million    |
| `web_searches`      | any            | 10 per search      |
| `attachments`       | any            | 5 per file         |

Each plan is one flat monthly price whose `grants` list fills two buckets. [Create the Base price](../../api-reference/catalog/prices/create). Price amounts are in cents, as decimal strings; credit amounts are in credits. The price has no `unit`, so the line's quantity is 1 and each `amountPerUnit` is a bucket size:

**`POST /v1/prices`**

```json title="POST /v1/prices"
{
  "product": "wingtip_chat",
  "name": "Base monthly",
  "displayName": "Wingtip Base",
  "currency": "usd",
  "type": "recurring",
  "recurring": {
    "interval": "month",
    "pricing": { "type": "perUnit", "perUnit": { "unitAmount": "2000" } },
    "grants": [
      {
        "creditCurrency": "wingtip_credits",
        "amountPerUnit": "2000",
        "grantedOn": "invoicePaid",
        "expiresAfter": { "value": "1", "unit": "month" }
      },
      {
        "creditCurrency": "wingtip_credits",
        "amountPerUnit": "50",
        "grantedOn": "invoicePaid",
        "expiresAfter": { "value": "1", "unit": "month" },
        "refill": { "every": { "value": "4", "unit": "hour" } }
      }
    ]
  }
}
```

The Premier price is the same with `"unitAmount": "20000"` and grants of `"20000"` and `"500"`. Both grants arrive when the invoice is paid, so a failed renewal refills neither.

[Create the plans](../../api-reference/catalog/plans/create), each with its price and the shared rate card:

**`POST /v1/plans`**

```json title="POST /v1/plans"
{
  "externalId": "base_monthly",
  "name": "Base",
  "displayName": "Wingtip Base",
  "lines": [
    { "type": "price", "price": { "price": "prc_base20Mo" } },
    { "type": "rateCard", "rateCard": { "rateCard": "wingtip_credit_rates" } }
  ],
  "upgradePath": { "group": "wingtip_monthly", "position": 1 },
  "default": true
}
```

`premier_monthly` uses the Premier price and `"position": 2`.

## Signing up a subscriber \[#signing-up-a-subscriber]

[Create the customer](../../api-reference/customers/customers/create) at sign-up, store its `cus_` ID on the user, and send it on every event:

**`POST /v1/customers`**

```json title="POST /v1/customers"
{
  "externalId": "user_51c9",
  "name": "Mara Ellison",
  "email": "mara@example.com",
  "currency": "usd"
}
```

[Create an order](../../api-reference/billing/orders/create) from the plan, starting at checkout:

**`POST /v1/orders`**

```json title="POST /v1/orders"
{
  "customer": "cus_8HqL2xT",
  "plan": { "plan": "base_monthly" },
  "startsAt": "2026-11-03T14:20:00Z",
  "billingCycle": { "interval": "month" },
  "paymentTerms": "dueOnReceipt"
}
```

Then [activate it](../../api-reference/billing/orders/activate) with `POST /v1/orders/ord_4Rt8Zp/activate`, which takes no body. Each invoice has one line, Wingtip Base at \$20.00: messages are paid in credits, and overage is never billed.

The 4-hour grant's windows start when the month's invoice is paid: a subscriber who paid at 14:20 refills at 14:20, 18:20, 22:20 and so on, back to 50 each time. Wingtip has nothing to schedule.

## Sending usage \[#sending-usage]

Before calling the model, Wingtip [holds](../../api-reference/credits/credit-holds/create) its estimate, assuming 2,000 output tokens; the check is atomic, so two messages at once can't both spend the last credits. For a small-model question with a web search, the estimate is 3.2 input + 8 output + 10 search = 21.2:

**`POST /v1/credit-holds`**

```json title="POST /v1/credit-holds"
{
  "customer": "cus_8HqL2xT",
  "creditCurrency": "wingtip_credits",
  "amount": "21.2",
  "correlationId": "msg_7f3a"
}
```

When the message finishes, Wingtip [sends one event](../../api-reference/metering/events/create) that names the hold. Paid prices the inference line from its catalog, so the event also records Wingtip's real cost:

**`POST /v1/events`**

```json title="POST /v1/events"
{
  "eventName": "message.completed",
  "customer": "cus_8HqL2xT",
  "product": "wingtip_chat",
  "dedupeKey": "msg_7f3a",
  "correlationId": "thread_2b91",
  "creditHold": "hold_Qm3v9",
  "timestamp": "2026-11-10T18:36:12Z",
  "payload": { "webSearches": 1, "attachments": 0 },
  "cost": [
    {
      "type": "inference",
      "inference": {
        "operation": "chat",
        "provider": "model-provider",
        "model": "model-small-2026-09",
        "inputTokens": 4000,
        "cacheReadInputTokens": 0,
        "outputTokens": 600
      }
    }
  ]
}
```

The event spends the actual 15.6 credits and settles the hold; the other 5.6 are free again. An actual above the hold is spent too, as unbilled overage if the balance runs out. If the provider errors before any output, Wingtip [releases the hold](../../api-reference/credits/credit-holds/release) with `POST /v1/credit-holds/hold_Qm3v9/release`. An unsettled hold lapses after 15 minutes. A hold the balance can't cover fails with `409`, so Wingtip shows the time to the next refill or offers a small model.

What typical messages cost:

| Message                     | Tokens                                 | Credits                                                   |
| --------------------------- | -------------------------------------- | --------------------------------------------------------- |
| Small-model question        | 4,000 in, 600 out                      | 4,000 × 800 ÷ 1M + 600 × 4,000 ÷ 1M = 3.2 + 2.4 = **5.6** |
| ... with a web search       | The same, plus 1 search                | 5.6 + 10 = **15.6**                                       |
| Large-model question        | 6,000 in, 800 out                      | 30 + 20 = **50**                                          |
| PDF analysis (large model)  | 62,000 in, 2,000 out, 1 file           | 310 + 50 + 5 = **365**                                    |
| Codebase dump (large model) | 250,000 in, 4,000 out                  | 1,250 × 2 (long context) + 100 = **2,600**                |
| Follow-up in that thread    | 256,000 in (250,000 cached), 3,000 out | 30 × 2 + 75 × 2 + 75 = **285**                            |

## How a session spends the buckets \[#spend-order]

Grants are spent soonest-forfeited first, counting a refilling grant's `nextRefillAt`. The 4-hour grant's credits are forfeited at its next refill and the monthly grant's at renewal, so the waterfall needs no configuration.

On 10 November at 18:35, in the 18:20 to 22:20 window, the subscriber has 50 in the 4-hour bucket and 1,700 left in the monthly bucket:

| Message               | Credits | 4-hour         | Monthly              |
| --------------------- | ------- | -------------- | -------------------- |
| Start                 |         | 50             | 1,700                |
| Small-model question  | 5.6     | 44.4           | 1,700                |
| ... with a web search | 15.6    | 28.8           | 1,700                |
| Large-model question  | 50      | 0 (28.8 spent) | 1,678.8 (21.2 spent) |
| PDF analysis          | 365     | 0              | 1,313.8              |

At 22:20 the 4-hour grant refills to 50, so 1,363.8 credits are spendable. A codebase dump at 22:50 needs about 2,600, so its hold fails with `409`, and Wingtip offers a small model or shows the time to the next refill.

## An illustrative month \[#the-month]

Each 30-day month has 180 4-hour windows, and each invoice is the flat plan price.

**A typical Base subscriber** (\$20.00 invoice), active in about 90 windows:

| Usage                                   | Messages | Credits each | Credits   |
| --------------------------------------- | -------- | ------------ | --------- |
| Small-model questions                   | 450      | 5.6          | 2,520     |
| Small-model questions with a web search | 40       | 15.6         | 624       |
| Large-model questions                   | 20       | 50           | 1,000     |
| PDF analyses                            | 4        | 365          | 1,460     |
| **Total**                               | **514**  |              | **5,604** |

3,800 credits come from the 4-hour bucket (of 9,000 offered; 5,200 lapse) and 1,804 from the monthly bucket (196 expire at renewal). 5,604 credits is \$5.60 of inference against \$20.00, a \$14.40 margin.

**A Premier subscriber** (\$200.00 invoice) who pastes codebases into a large model:

| Usage                       | Messages  | Credits each | Credits    |
| --------------------------- | --------- | ------------ | ---------- |
| Small-model questions       | 1,000     | 5.6          | 5,600      |
| Large-model questions       | 300       | 50           | 15,000     |
| Codebase dumps              | 8         | 2,600        | 20,800     |
| Follow-ups in those threads | 80        | 285          | 22,800     |
| PDF analyses                | 16        | 365          | 5,840      |
| **Total**                   | **1,404** |              | **70,040** |

The credits come from the 4-hour bucket (50,040 of 90,000 offered) and the whole monthly bucket (20,000): 70,040 in all, or \$70.04 of inference against \$200.00, a \$129.96 margin. The codebase threads alone cost 20,800 + 22,800 = 43,600 credits, 62% of the month.

## What subscribers see \[#balances]

The app shows each bucket and its countdown from [the subscriber's grants](../../api-reference/credits/credit-grants/list), `GET /v1/credit-grants?customer=cus_8HqL2xT&creditCurrency=wingtip_credits`. Each grant carries its own `available`, and `nextRefillAt` or `expiresAt`. At 18:40 in the session above, the 4-hour grant shows 28.8 with `nextRefillAt` 22:20 ("refills in 3h 40m"), and the monthly grant 1,700. The total spendable now, net of held credits, is on the [credit balance](../../api-reference/credits/credit-balances/list). Because a credit is pinned to \$0.001 of cost, [usage summaries](../../api-reference/metering/usage-summaries/list) grouped by `customer` show how close each subscriber comes to their price. The buckets cap it: a Base subscriber can spend at most 11,000 credits a month (\$11.00 against \$20.00), and a Premier one 110,000 (\$110.00 against \$200.00).

## Upgrading to Premier \[#upgrade]

A subscriber upgrades on 18 November, in the 3 November to 3 December period. [Preview the amendment](../../api-reference/billing/amendments/preview):

**`POST /v1/orders/ord_4Rt8Zp/amendments/preview`**

```json title="POST /v1/orders/ord_4Rt8Zp/amendments/preview"
{
  "changes": [{ "type": "changePlan", "changePlan": { "plan": "premier_monthly" } }],
  "expectedVersion": 1,
  "proration": "prorate"
}
```

The preview returns `direction: "upgrade"`. 18 November to 2 December is 15 of the period's 30 days, so Base is credited \$20.00 × 15 ÷ 30 = −\$10.00 and Premier charged \$200.00 × 15 ÷ 30 = \$100.00: **+\$90.00**. [Apply it](../../api-reference/billing/amendments/create) with `POST /v1/orders/ord_4Rt8Zp/amendments`, sending the same `changes` and `proration` plus the `previewToken`.

`changePlan` takes effect immediately, so Wingtip applies downgrades itself when the period ends.