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

# Margin Intelligence

> Cost and revenue visibility for AI products

AI products often bill per request, token, workflow, or model while serving costs vary by provider, model, usage pattern, and customer. Billing totals alone do not show whether each customer or plan is economically healthy.

**What Nozle provides:**

* Per-customer margin: how much you earn vs. spend on each customer
* Per-model margin: which LLM models are profitable vs. loss-leaders
* Per-metric margin: margin breakdown by feature
* Per-plan margin: which pricing tiers are profitable
* Trend analysis: margin over time with configurable granularity
* Margin simulation: what-if analysis for pricing changes

**How it works:**

1. You define cost models (what each unit costs you)
2. Nozle tracks usage events (what you charge customers)
3. Nozle computes margin = revenue - cost per event, per customer, per model
4. Data is stored for fast analytical queries
5. Query via SDK (nozle.margin.*) or API (GET /api/v1/margin/*)

**Access:**
All margin endpoints require a secret key (sk\_). Margin data is server-side only — it should not be exposed to customers.

The `can()` endpoint can return unit cost, revenue, and margin fields so your backend can log warnings or apply merchant-defined policy at decision time.
