# Self-Hosted AI Code Review & Cost Breakdown (Rio Code Review)

> Self-host AI code review on your own Cloudflare account with bring-your-own-key (BYOK) model routing, $0 per-seat fees, and 0% token markup.

Canonical HTML: https://getrio.dev/self-hosted

## Three transparent cost layers

1. **Local deterministic CLI (`rio review`)**: **$0 forever** (Apache-2.0 open source). Runs type checks, lint, changed-line coverage, secret scanning, dependency audits, SARIF export, and the local bounded impact graph with zero cloud account and zero API keys.
2. **Cloudflare Workers Paid account (`rio init`)**: **$5/month base** for unlimited developers.
   - Cloudflare Workers + Workflows: 10M requests and 30M CPU ms/month included.
   - Cloudflare D1: 25B rows read, 50M rows written, 5 GB storage included.
   - Cloudflare R2: $0.015/GB-month, $0 egress, 1M Class A + 10M Class B free operations/month.
   - Cloudflare Queues + AI Gateway: Queues $0.40/M ops after included tier; AI Gateway free core routing.
   - Cloudflare Sandbox or self-hosted Linux Docker runner: Containers included allowance (375 vCPU-min/mo, 25 GiB-hr, 200 GB-hr) or run `rio-runner` on your own Linux Docker host (`--runner self-hosted`).
3. **Model provider tokens (BYOK)**: **At cost (0% markup)**. Connect OpenRouter, Anthropic, OpenAI, or any OpenAI- or Anthropic-compatible endpoint. Illustrative per-PR averages: ~$0.04 (`--preset quick`), ~$0.12 (`--preset standard`), ~$0.35 (`--preset deep`), depending on diff size, prompt cache hits, and chosen models.

## Budget ceilings in YAML

```yaml
version: 1
name: team-bounded
extends: rio/openrouter
budget:
  fast:
    wall_time: 5m
    tokens: 100000
    verify_tokens: 20000
    agents_max: 3
```

If a budget ceiling is reached, Rio cancels remaining steps cleanly and exits with code `4` (incomplete analysis) rather than passing silently. Every report prints measured token usage, cache reads/writes, and price provenance.

## Deploying your endpoint

```sh
cf auth login
# Export OPENROUTER_API_KEY or ANTHROPIC_API_KEY in your private shell
rio init
rio review --profile rio/openrouter --preset standard
```

Preview without modifying your account using `rio deploy --dry-run`. Full hosting docs: https://getrio.dev/docs/hosting
