---
title: "Get factory cost per PR"
method: GET
path: "/factory/{uid}/costs/per-pr"
tags: ["Factories", "Metrics"]
---

# Get factory cost per PR

`GET /factory/{uid}/costs/per-pr`

## Request

- Base URL: `https://app.warp.dev/api/v1`
- URL: `https://app.warp.dev/api/v1/factory/{uid}/costs/per-pr`
- Auth: HTTP bearer

Mean per-PR attributed cost for a factory over a UTC date range,
with per-component dollar breakdowns. Previously served as
cost_per_pr on GET /factory/{uid}/metrics. Pass group_by_period to
additionally receive per-period series aligned to period_list.

## Path parameters

- `uid` string, required

## Query parameters

- `start_date` string, date-time
- `end_date` string, date-time
- `group_by_period` 'day' | 'week' | 'month': Binning granularity for factory metrics series. Weeks start on Sunday (UTC), consistent with existing Warp analytics.

## Response `200`

Cost per PR for the requested range

- FactoryCostPerPRResponse: Fields every factory-scoped metrics response carries alongside its data, so responses from several factories can be combined or told apart.
  - `as_of` string, date-time, required: The time the data is current as of. Data can lag live activity by a few minutes.
  - `team_uid` string, required: Public UID of the team that owns the factory.
  - `factory_uid` string, required: Public UID of the factory the response is scoped to.
  - `group_by_period` 'day' | 'week' | 'month': Binning granularity for factory metrics series. Weeks start on Sunday (UTC), consistent with existing Warp analytics.
  - `period_list` string[]: Period labels every series aligns to (dates like 2026-07-01; weeks labeled by their Sunday start date). Present only when group_by_period was requested.
  - `data` FactoryCostPerPRMetric, required: Cost per PR over the range, in US dollars: the cost of the run trees that produced PRs (split evenly across each tree's PRs so a cost is never double-counted), reported as the arithmetic mean of the per-PR costs.
    - `pr_count` integer, required: Distinct PRs (deduped by URL) first seen in the range. Matches pr_count.total today; kept separate so the cost denominator can diverge (e.g. merged-only) in the future.
    - `dollars` FactoryDollarsBreakdown, required: US dollars the owning team was billed, split by source component: compute (run execution), platform, and inference (recorded per conversation and counted once per distinct conversation). total is the sum of the three. Each charge contributes its recorded billed amount; charges recorded before billed amounts were tracked fall back to an estimated cost.
      - `compute` number, double, required
      - `platform` number, double, required
      - `inference` number, double, required
      - `total` number, double, required
    - `mean` number, double, nullable, required: Mean per-PR attributed cost, in US dollars; null when pr_count is 0.
    - `series` FactoryCostPerPRSeries: Per-period cost-per-PR series, aligned to period_list.
      - `pr_count` integer[], required: Distinct PRs first seen in each period.
      - `dollars` FactoryDollarsBreakdownSeries, required: Per-period dollar series aligned to period_list, zero-filled for periods with no attributed cost.
        - `compute` number[], required
        - `platform` number[], required
        - `inference` number[], required
        - `total` number[], required
      - `mean` number[], required: Mean per-PR attributed cost per period, in US dollars; null for periods with zero PRs.
      - `compute_mean` number[], required: Mean per-PR compute cost per period, in US dollars; null for periods with zero PRs.
      - `platform_mean` number[], required: Mean per-PR platform cost per period, in US dollars; null for periods with zero PRs.
      - `inference_mean` number[], required: Mean per-PR inference cost per period, in US dollars; null for periods with zero PRs.

## Other responses

- `400`: Invalid date range or group_by_period, or more than 365 periods requested
- `401`: Authentication required
- `403`: Factory access is not enabled for the authenticated principal
- `404`: Factory not found or not accessible
- `429`: The caller has used up the request budget shared by the factory metrics endpoints. Wait the number of seconds in Retry-After, then retry.
- `500`: Internal server error

## Changes

- **2026-10-21** `7ee3ba55debc`: 2 info
  - api tag `factory-metrics` added
  - api tag `factory` removed
- **2026-10-15** `f4630aae17ba`: 1 info
  - endpoint added

[Operation history](https://skmtc.dev/warp/apis/oz-agent-api/changes/factory/:uid/costs/per-pr/get.md)

---

[API](https://skmtc.dev/warp/apis/oz-agent-api.md) - [All operations](https://skmtc.dev/warp/apis/oz-agent-api/llms.txt) - [OpenAPI document](https://skmtc.dev/warp/apis/oz-agent-api/revisions/4b5d145669be?raw)
