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

# AI Cost Attribution Concepts

> Design stable customer and agent-step identifiers so Pylva cost reports map spend to accounts, workflows, and margin decisions.

Pylva is most valuable when every usage event answers two questions:

* Who caused this cost?
* Which part of the agent caused it?

## Customer identifiers

Use `customer_id` for the account, workspace, tenant, or end customer that caused the work.

Good values:

* `cust_abc123`
* `workspace_789`
* `acme-corp`

Avoid:

* Email addresses.
* Phone numbers.
* Raw names when an opaque ID is available.
* Any prompt or message content.

## Step names

Use `step_name` for the logical agent step that created spend.

Good values:

* `retrieve_context`
* `evaluate`
* `summarize`
* `draft_reply`
* `speak_answer`

Keep names stable. If a label changes every release, cost reports become hard to compare.

## Why attribution matters

Provider dashboards show a vendor bill. Pylva shows the customer and product path behind the bill.

| Question                             | What to filter by      |
| ------------------------------------ | ---------------------- |
| Which customers are expensive?       | `customer_id`          |
| Which workflow is expensive?         | `step_name`            |
| Which model causes margin drift?     | Provider and model     |
| Which non-LLM source changed margin? | Metric and cost source |

## Minimum useful event

An event should include:

* `customer_id`.
* `step_name`.
* Provider or metric.
* Usage counts such as tokens, requests, seconds, characters, or executions.
* Status and latency.

Pylva calculates `cost_usd` on the server.
