Developer workflow

AI Code Review Cost for GitHub Repositories

Estimate code review cost from the pull request diff, relevant repository context, review output, follow-up rounds, cache usage, and retries—not the repository's disk size alone.

Start with review scope, not repository size

Repository size can be misleading. A 500 MB repository might include dependencies, compiled assets, screenshots, datasets, or build output that should not be sent to a language model. A smaller 25 MB source-only repository can still contain millions of tokens because code is dense text.

Before estimating cost, exclude dependency folders, build output, minified bundles, generated files, logs, cache directories, large lockfiles, and binary assets unless they are directly relevant. Then measure a representative review payload: the PR diff, complete versions of changed files, imported or calling code, tests, repository instructions, and tool results.

Separate five usage buckets

Cached and uncached input must be disjoint. Do not price the full prompt at the ordinary input rate and then add the same cached tokens again. Cache eligibility and write or storage charges vary by provider, so use actual usage fields rather than assuming every repeated file is discounted.

The code review cost formula

Price every model call

Call cost = (new input tokens × input rate + cached input tokens × cached rate + billable output tokens × output rate) / 1,000,000

Review cost = sum of initial and follow-up call costs + tool and infrastructure charges

Monthly cost = reviews per month × average review cost + separately billed shared infrastructure

Worked example: one PR review with two follow-ups

Suppose the first review sends an 18,000-token diff, 42,000 tokens of relevant source and tests, 2,000 tokens of instructions, and 10,000 tokens of tool output. That is 72,000 input tokens. The review returns 3,000 output tokens.

Two follow-up calls each reuse 54,000 eligible cached tokens, add 8,000 new input tokens, and return 1,500 output tokens. At illustrative rates of $2 per million new input tokens, $0.20 per million cached input tokens, and $8 per million output tokens:

Illustrative dollar estimate

Initial review: (72,000 × $2 + 3,000 × $8) / 1,000,000 = $0.1680.

Each follow-up: (8,000 × $2 + 54,000 × $0.20 + 1,500 × $8) / 1,000,000 = $0.0388.

Total: $0.1680 + 2 × $0.0388 = $0.2456 per reviewed PR. At 600 comparable reviews per month, model usage is $147.36, before CI, tools, or cache storage.

These are illustrative rates, not a quote for any model or code-review product. Replace them with the current rates and usage categories for the service you use. If the follow-up context is not cache-eligible, price all 62,000 follow-up input tokens at the normal input rate instead.

Diff-only, targeted context, or full repository?

A diff-only review is cheapest but can miss effects in callers, schemas, tests, and permissions. Targeted context adds the complete changed files and a small set of related symbols. Full-project context can improve cross-file reasoning, but it does not mean every repository byte is sent to one prompt; an agent may search, retrieve, summarize, and make several model calls.

Estimate the workflow your tool actually performs. If usage is hidden behind a subscription or credit system, use the provider's billing report rather than converting repository size directly into API dollars. For GitHub Copilot code review specifically, GitHub says the automatically selected model is not disclosed and reviews can consume both token-based AI credits and GitHub Actions minutes.

Measure a representative review

  1. Choose small, typical, and large PRs; do not use only the repository's largest change.
  2. Record every call's new input, cached input, output, model, tool fees, and completion status.
  3. Group reruns after a new commit separately from retries caused by failures.
  4. Calculate average cost and a high-percentile case, then multiply by expected monthly review volume.

Also track cost per useful finding and cost per merged PR. A cheap review that creates many false positives can cost more developer time than it saves.

Reduce cost without removing needed context

Build a repository map once, then retrieve selected directories and symbols. Keep generated files and noisy logs out of prompts, return concise test failures, and reuse stable instructions where caching applies. Use a smaller model for file classification or summarization and a stronger model for cross-file, security-sensitive, or final verification work.

For multi-step review agents, the AI agent cost guide shows how growing history and partial retries affect cost. If stable repository instructions repeat across reviews, use the prompt caching guide to model eligible cache hits separately.

Current provider references

Checked August 29, 2026: GitHub's code review overview describes full-project context gathering. Its billing documentation explains that Copilot code review uses AI credits and GitHub Actions minutes and that the selected model is not disclosed. The worked example above models a generic token-priced API workflow, not Copilot plan billing.

Estimate your code review workload