Build an AI Code Reviewer with OpenRouter
Build an AI Code Reviewer with OpenRouter
This guide presents a 233-line Python script (review.py) that uses the OpenRouter Responses API with the Files API, Shell server tool, and Apply Patch server tool to run changed files in a hosted Linux sandbox, confirm bugs by executing checks, and return fixes as V4A patches. It covers setup, a five-bug sample repository, a Git pre-push hook, and a GitHub Actions workflow, with benchmark results across four models (e.g., Claude Sonnet 5.5 fixing all five bugs at $0.0447 and 60 seconds). The script writes a report to .git/ai-review.json and exits 1 when a finding meets the --block-at severity threshold.
It offers a concrete, reproducible implementation with cost and latency benchmarks, plus practical notes on API pitfalls, useful for developers building automated code review.
Source: OpenRouter Announcements · openrouter.ai