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

# AI & Infrastructure

> Token-based pricing, credits, and usage metering for AI companies

AI companies pioneered usage-based pricing with tokens, credits, and compute-based billing. This model aligns cost with value: customers pay proportionally to their consumption.

***

## Common AI Pricing Models

| Model              | How It Works                                     | Best For              | Examples                                    |
| ------------------ | ------------------------------------------------ | --------------------- | ------------------------------------------- |
| **Token-based**    | Price per million input/output tokens            | LLM APIs              | OpenAI ($2.50-15/M), Anthropic ($3-15/M)    |
| **Credit system**  | Pre-purchased credits consumed by usage          | Predictable budgeting | Many AI startups                            |
| **Compute-based**  | Price per GPU-hour or compute unit               | Training, inference   | AWS, GCP, Replicate                         |
| **Tiered + Usage** | Base subscription with usage included + overages | Consumer AI products  | ChatGPT Plus (\$20 + limits)                |
| **Outcome-based**  | Price per successful result                      | Task-specific AI      | Per document processed, per image generated |

***

## Recommended Alguna Setup

<Steps>
  <Step title="Create usage-based products">
    Navigate to **Products** → **Add Product**

    * Create "API Usage" as a metered product
    * Price per 1,000 or 1,000,000 tokens/units
    * Consider separate pricing for input vs. output tokens
  </Step>

  <Step title="Set up billable metrics">
    Navigate to **Billable Metrics** → **Create Metric**

    * Metric: "Input Tokens" (sum of input\_tokens property)
    * Metric: "Output Tokens" (sum of output\_tokens property)
    * Metric: "API Calls" (count of requests)
  </Step>

  <Step title="Implement credit system (optional)">
    Use Alguna's credits/wallet feature:

    * Customers pre-purchase credits
    * Usage depletes credits in real-time
    * Auto top-up when balance is low
    * Overage billing when credits exhausted
  </Step>

  <Step title="Create tiered pricing for volume">
    Reward high-volume customers:

    * First 1M tokens: \$3.00 per 1M
    * 1M - 10M tokens: \$2.50 per 1M
    * 10M+ tokens: \$2.00 per 1M
  </Step>

  <Step title="Set up real-time usage tracking">
    * Ingest usage events via API
    * Provide customers with usage dashboards in portal
    * Configure alerts at 50%, 80%, 100% of limits
  </Step>
</Steps>

***

## Billing Flow

```mermaid theme={null}
flowchart LR
    A[Customer Makes API Call] --> B[Usage Event Logged]
    B --> C{Credit System?}
    C -->|Yes| D[Deduct from Balance]
    C -->|No| E[Accumulate Usage]
    D --> F{Balance Low?}
    F -->|Yes| G[Auto Top-Up or Alert]
    E --> H[Monthly Invoice]
    H --> I[Pay-as-You-Go Charge]
```

***

## Credit System vs. Post-Paid

| Approach                   | Pros                                    | Cons                              | Best For                          |
| -------------------------- | --------------------------------------- | --------------------------------- | --------------------------------- |
| **Pre-paid credits**       | Predictable revenue, no collection risk | Friction to start, unused credits | Startups, SMB customers           |
| **Post-paid usage**        | Easy onboarding, pay for what you use   | Collection risk, bill shock       | Enterprise, established customers |
| **Hybrid (committed use)** | Volume discounts, predictable minimums  | Requires sales negotiation        | High-volume enterprise            |

***

## Key Features to Configure

<CardGroup cols={2}>
  <Card title="Billable Metrics" icon="chart-line" href="/billable-metrics/define-metrics">
    Define what usage events to track and how to aggregate them.
  </Card>

  <Card title="Credits & Wallets" icon="wallet" href="/credits/overview">
    Set up pre-paid credit systems with auto top-up.
  </Card>

  <Card title="Usage Metering" icon="gauge" href="/billable-metrics/send-usage">
    Ingest usage events and see real-time consumption.
  </Card>

  <Card title="Customer Portal" icon="browser" href="/hosted/customer-portal">
    Let customers view their usage and manage billing.
  </Card>
</CardGroup>

***

## API Reference

<CardGroup cols={2}>
  <Card title="Ingest Events" icon="upload" href="/api-reference/events/ingest">
    Send usage events to Alguna.
  </Card>

  <Card title="Credit Grants API" icon="coins" href="/api-reference/credit-grants/create">
    Manage customer credit balances.
  </Card>

  <Card title="Webhooks" icon="webhook" href="/api-reference/webhooks">
    Get notified of billing events.
  </Card>

  <Card title="Customers API" icon="users" href="/api-reference/customers/create">
    Create and manage customer accounts.
  </Card>
</CardGroup>

***

## Related Quick Starts

<CardGroup cols={3}>
  <Card title="Self-Serve (PLG)" icon="cart-shopping" href="/quickstarts/self-serve">
    Most AI companies start with self-serve checkout.
  </Card>

  <Card title="Developers" icon="code" href="/quickstarts/developers">
    API integration for usage metering.
  </Card>

  <Card title="Hybrid Motion" icon="arrows-split-up-and-left" href="/quickstarts/hybrid-motion">
    Land self-serve, expand with sales for enterprise.
  </Card>
</CardGroup>

<Card title="← Back to Quick Starts" icon="arrow-left" href="/quickstarts/overview">
  See all quick start guides
</Card>
