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

# AI Product Billing

> Set up flexible billing for AI products and API services

## Who Is This For?

This guide is for developers building AI products, API services, or any usage-based business. Common examples:

| Business Type      | Examples                                                  |
| ------------------ | --------------------------------------------------------- |
| AI API Services    | LLM API proxies, image generation, speech recognition     |
| AI SaaS            | AI writing assistants, AI code completion, AI translation |
| AI Agent Platforms | Automated workflows, data analysis agents                 |
| API Services       | Payment processing, messaging, data queries               |

***

## How Billing Works with Waffo Pancake

Waffo Pancake does not provide built-in usage metering, but you can model AI billing with two primary approaches: `subscriptions` and `on-demand purchases`. In many businesses, these two approaches work best together.

### Approach 1: Subscriptions

Create subscription products at different tiers, each with a different token quota, request allowance, or task limit.

> Prices below are examples only. Set them based on your actual business and costs.

| Plan        | Monthly     | Token Quota | Best For              |
| ----------- | ----------- | ----------- | --------------------- |
| **Starter** | \$9/month   | 100K tokens | Individual developers |
| **Pro**     | \$49/month  | 1M tokens   | Small teams           |
| **Scale**   | \$199/month | 10M tokens  | Enterprise            |

Best for:

* recurring monthly or annual access
* plans with included usage
* upgrade paths that unlock higher quotas

### Approach 2: On-Demand Purchases

Use one-time orders or dynamic pricing to charge based on additional usage, credits, or runtime-calculated amounts.

Best for:

* buying extra tokens or credits
* charging for overage beyond the included plan
* per-task, per-call, or quoted usage

#### Dynamic Pricing via Checkout Session

Pass dynamic pricing through `priceSnapshot` when creating a checkout session to charge based on actual usage.

```typescript theme={"system"}
const session = await client.checkout.createSession({
  storeId: "store_id",
  productId: "usage-product-id",
  productType: "onetime",
  currency: "USD", // replace with your currency
  priceSnapshot: {
    amount: calculatedAmount, // dynamically calculated based on usage
    taxIncluded: false,
    taxCategory: "saas",
  },
});
```

### External Metering Tools

Use dedicated metering tools to track usage, combined with Waffo Pancake for billing.

***

## Recommended Metering Tools

<Card title="New API" icon="bolt" href="https://github.com/QuantumNous/new-api">
  API aggregation and management platform with multi-model key distribution, usage tracking, and quota control. Waffo Pancake partner.
</Card>

***

## Recommended Combination

<Note>
  Most AI products do not need to choose only one billing model. The most common pattern is to combine subscriptions with on-demand purchases.
</Note>

### Combined Pattern: Base Subscription + On-Demand Usage

This is the most common and easiest billing model for customers to understand.

**Setup:**

1. Create tiered subscription products such as Starter / Pro / Scale
2. Include a fixed quota of tokens, requests, or tasks in each plan
3. Track actual usage with an external metering system
4. When a user exceeds the included quota, charge extra through a one-time order or `priceSnapshot`

**Fits well for:**

* AI API services
* AI SaaS
* AI agent platforms

**Dashboard workflow:**

* Monitor active plans in **Subscriptions**
* Review extra purchases or overage charges in **Payments**
* Track subscription revenue and on-demand revenue together in **Analytics**

***

## Key Webhook Events

| Event                    | Action                                              |
| ------------------------ | --------------------------------------------------- |
| `subscription.activated` | Set initial token/request quota                     |
| `subscription.updated`   | Adjust quota to match new plan                      |
| `subscription.canceled`  | Revoke API access or downgrade to free tier         |
| `subscription.past_due`  | Reduce quota or throttle API calls                  |
| `order.completed`        | Grant additional token allowance (overage purchase) |

For API details, see the [API Reference](/api-reference/introduction).

***

## Testing

<Steps>
  <Step title="Create Test Products">
    Set up both subscription products and on-demand products in test mode.
  </Step>

  <Step title="Subscribe with Test Card">
    Use `4576 7500 0000 0110` to subscribe to each tier.
  </Step>

  <Step title="Simulate Usage">
    Test your usage tracking and quota enforcement logic.
  </Step>

  <Step title="Test On-Demand Billing">
    Verify the dynamic pricing and on-demand billing flow.
  </Step>
</Steps>

***

## Launch Checklist

* [ ] Subscription products created for each tier
* [ ] On-demand or overage product created
* [ ] Pricing and quotas clearly documented
* [ ] Usage tracking/metering tool integrated
* [ ] Quota enforcement working correctly
* [ ] Upgrade/downgrade flows tested
* [ ] On-demand billing flow verified
* [ ] Products published to production

***

## Next Steps

<CardGroup cols={2}>
  <Card title="Run SaaS Subscriptions" icon="repeat" href="/guides/subscriptions">
    Learn more about subscription management
  </Card>

  <Card title="Set Up Webhooks" icon="webhook" href="/guides/webhooks">
    Automate quota management with webhooks
  </Card>
</CardGroup>
