---
description: Calculate model cost from tokens, service tiers, prompt size, and custom pricing rules.
---

# Model pricing

WeaveScope calculates model cost when an observation includes token usage but
does not provide an explicit cost. Pricing rules apply across the organization.

Model cost is observability data. It is separate from your WeaveScope
subscription and ingestion charges.

## Where cost appears

You can see model cost in:

- The trace table
- Trace headers
- Model observation details
- Monitoring cost charts

Use these views to compare spend by trace, model, user, release, tag, or other
searchable context.

{% hint style="info" %}
Changing a model-pricing rule affects trace and monitoring cost. It does not
change your WeaveScope plan, limits, or overage charges.
{% endhint %}

## Managed pricing

WeaveScope includes managed pricing for:

- OpenAI
- Gemini
- Anthropic
- Kimi/Moonshot
- xAI
- Z.ai
- DeepSeek

Managed rules are maintained by WeaveScope and cannot be edited. Open
**Settings → Model pricing** to see the models, effective prices, service tiers,
prompt-size bands, cache behavior, and provider notes currently available.

Because provider catalogs and rates change frequently, use that page rather
than copying prices into application configuration.

## Custom pricing

Add a custom rule when your model is not in the managed catalog.

| Field | Meaning |
| --- | --- |
| Provider | Provider label shown in WeaveScope. |
| Name | Display name for the rule. |
| Model ID | Exact identifier emitted in trace metadata. |
| Input price | USD per 1 million input tokens. |
| Cached input price | USD per 1 million cached input tokens. |
| Output price | USD per 1 million output tokens. |

The model ID must exactly match the value shown in trace details. A custom rule
created from one project can price matching observations in every project in
the organization.

## How cost is selected

For each observation, WeaveScope:

1. Uses an explicit event cost, such as `cost_usd`, `cost`, or `total_cost`,
   when present.
2. Otherwise finds a matching organization pricing rule.
3. Applies token, cache, service-tier, prompt-size, and geography information
   supported by that rule.
4. Uses `0` if it has neither an explicit cost nor a matching rule.

## Token formula

For a matching rule:

```text
uncached_input_tokens =
  input_tokens - cached_input_tokens - cache_creation_tokens

cost =
  uncached_input_tokens * input_price_per_token +
  cached_input_tokens * cached_input_price_per_token +
  cache_creation_tokens * cache_creation_price_per_token +
  output_tokens * output_price_per_token
```

WeaveScope derives per-token values from the configured prices per million
tokens.

If a cached-input or cache-creation price is unavailable, the normal input
price applies to those tokens.

## Tiered pricing

Managed rules can distinguish service tiers such as:

- `standard`
- `batch`
- `fast`
- `flex`
- `priority`

When an observation includes service-tier metadata, WeaveScope uses the
matching tier when available and otherwise falls back to `standard`. Cost is
based on the tier the provider reports as served, not only the tier requested.

Some managed rules also select prices by input-token count or inference
geography. When supported, WeaveScope applies the matching prompt-size band or
geography multiplier from the observation metadata.

## Why cost can be zero

Cost remains zero when:

- The event has no explicit cost.
- Token usage is missing.
- Provider or model metadata does not match a pricing rule.
- A custom rule uses a different model ID from the trace.
- The model is outside the managed catalog and has no custom rule.

Open the model observation in **Tracing → Details** and copy the exact provider
and model values into the custom rule.

## Pricing changes and historical traces

WeaveScope records calculated cost when it ingests an observation. Updating a
pricing rule affects future observations only.

Existing traces keep their original cost unless an operator explicitly replays
or backfills them.
