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

# Build vs Buy

> What it takes to build AI monetization yourself — and what Lava handles for you

export const providerCountLabel = "185+";

Before you build your own AI monetization system, here's everything you'd need to implement, maintain, and scale. Lava handles all of it out of the box — the only decision is which integration path fits your architecture.

***

## What you'd need to build

| Capability                                   | Lava AI Gateway  | Lava Post-Request     | Build It Yourself |
| -------------------------------------------- | ---------------- | --------------------- | ----------------- |
| **Cost tracking**                            | Automatic        | You forward responses | You build         |
| **Usage metering**                           | Automatic        | You forward responses | You build         |
| **Pricing configuration** (fixed, %, tiered) | Included         | Included              | You build         |
| **Subscription & plan management**           | Included         | Included              | You build         |
| **Credit & wallet system**                   | Included         | Included              | You build         |
| **Overages**                                 | Included         | Included              | You build         |
| **Auto top-ups**                             | Included         | Included              | You build         |
| **Usage alerts**                             | Included         | Included              | You build         |
| **Hosted checkout flow**                     | Included         | Included              | You build         |
| **Payment processing** (Stripe)              | Included         | Included              | You build         |
| **Front-end components** (balances, plans)   | Lava SDKs & APIs | Lava SDKs & APIs      | You build         |
| **Enforce usage limits** (pre-request)       | Automatic        | Check via Lava SDK    | You build         |
| **Revenue dashboard**                        | Included         | Included              | You build         |
| **Per-customer usage analytics**             | Included         | Included              | You build         |
| **Margin visibility**                        | Included         | Included              | You build         |

That's 15 systems to design, build, test, and maintain — on top of the product you're actually trying to ship.

***

## The hidden costs of building it yourself

### Metering is harder than it looks

Every AI provider returns usage data differently. OpenAI gives you `prompt_tokens` and `completion_tokens`. Anthropic gives you `input_tokens` and `output_tokens`. Google uses `promptTokenCount` and `candidatesTokenCount`. Voice providers bill by the second. Image providers bill per generation.

You'd need to write and maintain parsers for every provider you use, handle streaming responses where token counts arrive at the end, and normalize everything into a single billing unit. Lava does this across {providerCountLabel} providers automatically.

### Billing logic compounds

A credit system sounds simple until you need overages, tiered pricing, auto top-ups, subscriptions with included credits, prorated refunds, and audit trails. Each feature interacts with the others. Tiered pricing changes how overages work. Subscriptions need to interact with the credit system. Auto top-ups need to trigger at the right threshold without race conditions.

### Enforcement requires being in the request path

If you want to block requests when a customer is out of credits, you need a proxy or middleware that checks balances before every API call — with sub-20ms latency so you don't slow down responses. That's infrastructure you'd need to build, deploy, and keep highly available.

### Checkout and payments are their own product

Stripe integration, PCI compliance, hosted checkout flows, payment method management, failed payment retry logic, webhook handling — this is months of work that has nothing to do with your core product.

***

## Two ways to integrate Lava

Both paths give you the full billing stack. The difference is how usage data gets into the system.

### AI Gateway

Route your AI requests through Lava. One URL change — Lava handles metering, billing, and enforcement automatically.

```bash theme={null}
# Before: direct to provider
curl https://api.openai.com/v1/chat/completions

# After: through Lava
curl https://api.lava.so/v1/forward?u=https://api.openai.com/v1/chat/completions
```

**Best for:** Most AI apps. Fastest integration, automatic enforcement, works across all {providerCountLabel} supported providers.

### Post-Request Metering

Call your AI provider directly and forward the response to Lava for billing. You keep your existing request path — Lava handles everything after the request.

**Best for:** Apps deeply integrated with provider SDKs, providers Lava doesn't proxy yet, or non-AI usage billing.

<Tip>
  Not sure which to pick? See [How Lava Gateway Works](/gateway/how-lava-gateway-works) for a detailed look at the proxy path.
</Tip>

***

## Next steps

<CardGroup cols={2}>
  <Card title="Quickstart" icon="rocket" href="/get-started/quickstart-track">
    Get billing running in under 10 minutes
  </Card>

  <Card title="How Lava Monetize Works" icon="receipt" href="/monetize/how-lava-monetize-works">
    Step-by-step setup for both integration paths
  </Card>

  <Card title="Supported Providers" icon="grid" href="/gateway/supported-providers">
    See all {providerCountLabel} AI providers Lava supports
  </Card>

  <Card title="Pricing Configuration" icon="dollar-sign" href="/monetize/meters">
    Configure meters with tiered pricing and markups
  </Card>
</CardGroup>
