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

# PR AI cost

> Estimated AI coding agent cost behind each pull request, for Claude Code, Codex, and other tools

PR AI cost estimates how much AI coding agent usage went into each pull request. Weave looks at every prompt an engineer sends to their coding agent, works out which PR that prompt contributed to, and adds the prompt's cost to that PR. It works with Claude Code, Codex, and other coding agents that report to Weave through a Weave plugin.

The number is shown as **Estimated API-equivalent AI cost**, so it reflects how much AI work went into the PR rather than what your invoice says. When the coding agent's telemetry reports a cost for a request, as Claude Code does, Weave uses that cost as is, even when it's \$0. Otherwise Weave prices the request's tokens at list rates. For billed spend per engineer, see [AI tool costs](https://docs.weaveos.com/metrics/ai-tool-costs.md).

## Where you'll see it

* **PR drill-downs**: an **Estimated API-equivalent AI cost** column on PR lists across Weave reports
* **Projects and workstreams**: AI spend and AI cost per output for each project, task, and workstream, rolled up from the PRs linked to them

> [!NOTE]
>
> PR AI cost is enabled per organization. Contact your Weave representative to turn it on.

## How it works

**1. Collect priced prompts**

The coding agent's Weave plugin reports each prompt with its session, git branch, repository, and the files the agent read, edited, or touched with shell commands. Weave prices each prompt from the cost its telemetry reports, or from its token usage at list rates when no cost is reported.

**2. Find candidate PRs**

Weave matches the prompt's branch and repository to PRs opened from that branch. A prompt can count toward a PR from up to 14 days before the PR was opened until it closes.

**3. Anchor prompts to a PR**

A prompt is **anchored** to a PR when the files it worked on are files that PR changed. With [git attribution](https://docs.weaveos.com/ai-tools/git-attribution.md) installed, a prompt is also anchored when its session made a commit that ended up in the PR.

**4. Attribute the surrounding prompts**

Prompts in the same session that didn't touch PR files themselves, such as planning, questions, or debugging, are attributed to the PR when they fall between two prompts anchored to it, or when they lead up to its first anchored prompt.

Prompts on `main`, `master`, `develop`, or `dev`, and prompts that can't be tied to any PR, are left out of PR AI cost. They still count toward [AI tool costs](https://docs.weaveos.com/metrics/ai-tool-costs.md).

## Supported coding agents

| Coding agent | Required setup |
| - | - |
| **Claude Code** | [Claude Code plugin](https://docs.weaveos.com/ai-tools/claude-code-plugin.md) and [Claude Code telemetry](https://docs.weaveos.com/ai-tools/claude-code.md) connected to Weave |
| **Codex** | [Codex plugin](https://docs.weaveos.com/ai-tools/codex-plugin.md) |
| **Other coding agents** | That tool's [Weave plugin](https://docs.weaveos.com/ai-tools/overview.md) |

## Requirements

PR AI cost only covers work from engineers whose machines meet these requirements. If only some of your engineers have them set up, PR AI cost will look sparse, because PRs written without them show little or no cost.

### For every coding agent

* **The coding agent's Weave plugin is installed on each engineer's machine.** The plugin reports the branch, repository, and file activity for each prompt. Without it, Weave can't tie a prompt to a PR.
* **Each engineer's plugin account is connected to their Weave member.** Prompts from unlinked accounts aren't counted.
* **The repository is connected to Weave.** The repository the engineer works in must match a repository synced from your [code platform](https://docs.weaveos.com/code-platforms/overview.md), so Weave can see its PRs and changed files.
* **Work happens on a feature branch.** Prompts sent while on `main`, `master`, `develop`, or `dev` aren't attributed.
* **The plugin's content categories allow git and file data.** Keep `git_context`, `file_paths`, and `tool_io` allowed in your organization's content policy. Without them, the plugin can't report the branch or files a prompt touched.

### Claude Code

* Install the [Claude Code plugin](https://docs.weaveos.com/ai-tools/claude-code-plugin.md) on each engineer's machine.
* Connect [Claude Code telemetry](https://docs.weaveos.com/ai-tools/claude-code.md#setup) to Weave. Weave uses Claude Code's native telemetry for the cost of each request, and the plugin to tie each request to its branch and files.

### Codex

* Install the [Codex plugin](https://docs.weaveos.com/ai-tools/codex-plugin.md) on each engineer's machine. It turns on Codex's native telemetry for usage and cost, and its hooks capture the branch and files each turn changed.
* Trust the Weave hooks when Codex asks after install. Without them, Codex reports cost but not branch or file activity.

### Git attribution (strongly recommended)

[Git attribution](https://docs.weaveos.com/ai-tools/git-attribution.md) isn't required, but we strongly recommend it for accurate results. Git-ai records which AI session wrote the code in each commit, which lets Weave tie a prompt to a PR through the commit itself instead of relying only on branch names and file paths.

This matters most when an engineer's git workflow doesn't line up neatly with their PRs:

* The PR is opened from a different branch than the one the code was written on, such as after a rename, cherry-pick, or from a worktree or fork
* Files the agent edited were later renamed, moved, or reverted, so they no longer appear in the PR's changed files
* The plugin missed the file activity for a prompt, or the agent changed files only through shell commands
* The work happened well before the PR was opened

Install git attribution on the same machines as the coding agent plugin, with its hooks configured for each coding agent.

## FAQ

> [accordion] Why do some PRs show no AI cost?
>
> The PR was most likely written without a supported coding agent, or on a machine without the coding agent's Weave plugin. Other common causes are an unlinked plugin account, work done on a default branch, or a content policy that blocks git and file data. Installing [git attribution](https://docs.weaveos.com/ai-tools/git-attribution.md) helps when the PR was opened from a different branch than the one the code was written on.

> [accordion] Why doesn't PR AI cost add up to my AI tool spend?
>
> PR AI cost only includes prompts that can be tied to a PR, and it uses the cost the coding agent reports or list-rate token pricing rather than your billed rates. Requests the agent reports at \$0 add nothing. [AI tool costs](https://docs.weaveos.com/metrics/ai-tool-costs.md) include all usage, seat costs, and billed amounts from provider APIs.

> [accordion] Can one prompt count toward more than one PR?
>
> Yes. When a prompt matches more than one PR, Weave splits its cost evenly across those PRs.

## Related

* [AI tool costs](https://docs.weaveos.com/metrics/ai-tool-costs.md): AI spend per engineer and by tool
* [Claude Code plugin](https://docs.weaveos.com/ai-tools/claude-code-plugin.md)
* [Codex plugin](https://docs.weaveos.com/ai-tools/codex-plugin.md)
* [Git attribution](https://docs.weaveos.com/ai-tools/git-attribution.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.