Cost model types
| Type | Use case | How it works |
|---|---|---|
per_unit | Fixed cost per event | Every event costs the same (e.g. $0.03 per API call) |
per_model | LLM token pricing | Different rates per model (GPT-4o costs more than GPT-4o-mini) |
tiered | Volume discounts | Cost per unit changes at thresholds |
Create a cost model (sk_ key required)
Per-model (recommended for LLM)
model, input_tokens, and output_tokens properties.
Per-unit
Tiered
List cost models
Delete a cost model
How it connects to margin
Once a cost model is configured, every usage event matching themetric_code is automatically enriched with cost data:
- SDK sends
nozle.track(customerId, "llm_tokens", { model: "gpt-4o", input_tokens: 500, output_tokens: 200 }) - The margin engine looks up the cost model for
llm_tokens - For
per_modeltype: calculates(500 × 250 + 200 × 1000) / 1,000,000 = $0.000325 - Stores revenue, cost, and margin in the margin events table
- Dashboard shows per-customer, per-model, per-feature margin breakdown