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

# AI P&L: measuring the financial impact of AI

> AI P&L rolls up every decision, linked financial event, and active liability estimate into four numbers that answer: is this AI making or losing money?

AI P\&L is the top-level view that rolls up every decision, every linked financial event, and every active liability estimate into a single answer to the question: is this AI making or losing money? It is the number finance looks at, the number leadership asks about, and the number a board slide summarises in two bullets. That visibility is only meaningful if you trust the computation — and the computation is intentionally transparent: pure aggregates over the same ledger you can query manually via the REST API. If a dashboard number ever disagrees with a REST call over the same range, the REST call is authoritative. The dashboard is a presentation of the ledger, not a separate source of truth.

## The four numbers

The AI P\&L is per-org, per-time-range, and optionally per-agent. Pass a date range and an optional agent ID and you get:

<CardGroup cols={2}>
  <Card title="total_revenue_attributed" icon="trending-up">
    SUM of `amount` across linked financial events whose consequence-link `link_type` is `revenue`, within the requested range.
  </Card>

  <Card title="total_cost_attributed" icon="trending-down">
    SUM of `amount` across linked financial events whose consequence-link `link_type` is `cost`, within the requested range.
  </Card>

  <Card title="total_liability_exposure" icon="triangle-alert">
    SUM of `estimated_exposure` across active liability estimates for in-range decisions. This is a separate aggregation over the liability estimates — not derived from the event ledger.
  </Card>

  <Card title="net_ai_impact" icon="circle-dollar-sign">
    `total_revenue_attributed − total_cost_attributed`. Prospective liability is reported separately and is **not** subtracted from net impact.
  </Card>
</CardGroup>

The response also includes `decision_count`, `link_count`, and a `top_agents` array listing the five biggest net-impact contributors.

## Shape

```json theme={null}
{
  "currency": "USD",
  "total_revenue_attributed": "148230.00",
  "total_cost_attributed":    "-12400.50",
  "total_liability_exposure":  "67500.00",
  "net_ai_impact":            "135829.50",
  "decision_count": 4123,
  "link_count": 2987,
  "top_agents": [
    { "agent_id": "pricing-bot",  "net_impact":  "82100.00", "decision_count": 1204 },
    { "agent_id": "refund-bot",   "net_impact":  "22400.00", "decision_count": 890 },
    { "agent_id": "upsell-bot",   "net_impact":  "19300.00", "decision_count": 612 }
  ]
}
```

## Fetching from code

<CodeGroup>
  ```python Python theme={null}
  pnl = pq.get_ai_pnl(
      start="2026-04-01",
      end="2026-04-30",
      agent_id="pricing-bot",    # optional — per-agent slice
  )
  if pnl is not None:
      print(pnl["net_ai_impact"], pnl["currency"])
  ```

  ```typescript TypeScript theme={null}
  const pnl = await pq.getAiPnl(
    { start: '2026-04-01', end: '2026-04-30' },
    'pricing-bot', // optional — per-agent slice
  );
  if (pnl) {
    console.log(pnl.netAiImpact, pnl.currency);
  }
  ```
</CodeGroup>

## Currency handling

The endpoint aggregates only when every in-range linked event shares a single currency. If your org's events span multiple currencies, the endpoint returns **HTTP 409** with a `currencies` detail array so you can retry scoped to one currency at a time using the `start`/`end` window.

<Info>
  If you need a single rolled-up number across currencies today, convert at ingestion time before posting financial events. The dashboard's P\&L view collapses mixed-currency orgs into per-currency panels automatically.
</Info>

## What is NOT in the P\&L

<AccordionGroup>
  <Accordion title="Pending events with no link">
    The P\&L only counts events with an active consequence link. An event that the attribution engine scored below the suggest threshold (below 0.4) is discarded and does not appear anywhere in the P\&L. See [Consequence Links](/concepts/consequence-links) for how links are created and scored.
  </Accordion>

  <Accordion title="Soft-deleted links">
    When a human rejects an ML-suggested link, the link is soft-deleted and excluded from all P\&L queries. Forensic exports still include it so an external reviewer can see that a prior attribution was retracted.
  </Accordion>

  <Accordion title="Liability losses">
    Liability is an estimate, not a realised loss. If a liability actually materialises — a lawsuit settles, a refund is paid — it enters the ledger as a `cost` financial event, which flows into `total_cost_attributed`, not into `total_liability_exposure`.
  </Accordion>

  <Accordion title="NEUTRAL and LIABILITY link types">
    `NEUTRAL` links are audit metadata with an explicit zero P\&L effect. `LIABILITY` link types flow into the exposure column only — they are excluded from the revenue and cost sums.
  </Accordion>
</AccordionGroup>

<Tip>
  Use the timeline endpoint (`/api/v1/analytics/timeline`) to get these same four numbers bucketed by `hour`, `day`, `week`, or `month`. The dashboard's area chart reads it directly — and you can pipe it to your own BI tooling using the same query parameters.
</Tip>
