OpenRouter 指南构建基于沙箱的 AI 代码审查器
OpenRouter 发布了一份 233 行 Python 脚本,使用 OpenRouter Responses API 将变更文件、测试或其他上下文文件以及 Git diff 上传至托管 Linux 沙箱。模型可在沙箱中运行检查,以复现疑似缺陷并提出 V4A 补丁。该脚本可本地运行,也可用于 Git pre-push hook 或 GitHub Actions,并将审查结果标记为已确认或未确认,已确认结果会附有命令和输出。在 OpenRouter 对四个模型进行的一项五缺陷变更自测中,每次审查耗时 1 至 4 分钟,成本为 0.015 至 0.045 美元。Files API、Shell 工具和 Apply Patch 工具仍是 beta 功能,其行为可能变化;模型也可能漏报缺陷、夸大严重性或生成无法使用的补丁。
该指南提供了一套具体方案,让 AI 代码审查结果建立在运行时检查之上,而不是仅依靠 diff 分析。它还区分了已确认结论和需要人工复核的未确认备注。
Build an AI Code Reviewer with OpenRouter
OpenRouter ·11/1/2026


An AI code reviewer checks a Git change for bugs and security issues before you push or merge. Reviewers that only read the diff have to guess what the rest of the file looks like and whether a suspected bug actually fails at runtime, and their suggested fixes come back as text you copy in by hand.
The reviewer in this guide uses the OpenRouter Responses API to run your changed files in a Linux sandbox, confirm each bug by running a check, and return fixes as patches you can apply with a flag. Across the four models we tested on a five-bug change, a review takes one to four minutes and costs between $0.015 and $0.045.
#OpenRouter#OpenRouter Responses API#OpenRouter Files API#OpenRouter Shell tool#OpenRouter Apply Patch tool#Claude Haiku 5.5#Claude Sonnet 5.5#GPT-6 Luna#DeepSeek V4.1 Flash