Skip to main content
Cost models tell Nozle what each unit of usage costs you. Without cost models, the margin engine can’t calculate your AI spend.

Cost model types

Create a cost model (sk_ key required)

Rates are in cents per 1M tokens. The margin engine calculates cost automatically when events arrive with 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 the metric_code is automatically enriched with cost data:
  1. SDK sends nozle.track(customerId, "llm_tokens", { model: "provider-model-large", input_tokens: 500, output_tokens: 200 })
  2. The margin engine looks up the cost model for llm_tokens
  3. For per_model type: calculates (500 × 250 + 200 × 1000) / 1,000,000 = $0.000325
  4. Stores revenue, cost, and margin in the margin events table
  5. Dashboard shows per-customer, per-model, per-feature margin breakdown