Guide · Open source
How to use pr-agent: install, run reviews and set up API keys
Updated · written with AI from the project's own documentation and checked against our catalogue data
PR Agent is an open-source tool that uses a large language model to review code changes in pull requests on GitHub, GitLab, Bitbucket and Azure DevOps. It can post a summary, a review or improvement suggestions as comments, and you can ask it questions about a PR. This guide walks through the two main setups from the README, a GitHub Action and a local CLI, so you can run your first review.
Quick start
- 1Check prerequisites. Make sure Python is installed and you have an API key for an AI model provider such as OpenAI.
- 2Install the CLI. Run pip install with the extra for your git provider, such as pr-agent[github].
- 3Set your API key. Export your model key as an environment variable, for example OPENAI_KEY.
- 4Run a review. Run pr-agent with a --pr_url flag pointing to a pull request, followed by the tool name review.
- 5Try a GitHub Action. Add the workflow file to .github/workflows and store your model key as a repository secret.
- 6Comment commands on a PR. Type /review, /improve or /ask in a PR comment to run tools on that pull request.
What you need before you start
PR Agent is a self-hosted tool that you configure yourself. The README lists Python and an API key for an AI model provider such as OpenAI as prerequisites.
Git provider SDKs are optional extras. You install the one for your provider, or use the all extra for every integration.
- Python
- An API key for an AI model provider such as OpenAI
- A repository on GitHub, GitLab, Bitbucket or Azure DevOps
Install PR Agent with pip for local use
For local development, install the CLI with the extra for your git provider. The README's example uses GitHub support, then sets your model key as an environment variable.
- Install with GitHub support, or pr-agent[all] for every integration.
- Set your model API key in the environment before running.
pip install "pr-agent[github]"
export OPENAI_KEY=your_key_hereRun your first review from the command line
Point the CLI at a pull request URL and name the tool to run. The README example runs the review tool on a GitHub PR.
You can also run tools on an issue. The README shows a similar_issue command that takes an issue URL.
- Replace the example URL with your own PR URL.
- Other tools shown in the README include /describe, /improve and /ask.
pr-agent --pr_url https://github.com/owner/repo/pull/123 reviewSet up PR Agent as a GitHub Action
The README lists the GitHub Action as the recommended option for adding automated reviews to a repository. You add a workflow file that runs on pull request events and pass your model key and GITHUB_TOKEN as secrets.
The workflow in the README runs on pull requests with the opened and synchronize types. Store OPENAI_KEY as a repository secret rather than in the file.
- Create .github/workflows/pr-agent.yml in your repository.
- Add OPENAI_KEY as a repository secret.
- The full setup guide is in the project docs at docs.pr-agent.ai.
name: PR Agent
on:
pull_request:
types: [opened, synchronize]
jobs:
pr_agent_job:
runs-on: ubuntu-latest
steps:
- name: PR Agent action step
uses: the-pr-agent/pr-agent@main
env:
OPENAI_KEY: ${{ secrets.OPENAI_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}Use PR Agent commands in a pull request
Once set up, you run tools by commenting on a PR. Each tool, such as /review, /improve and /ask, makes a single LLM call according to the README. The /ask command takes a free-text question in quotes.
The README says PR Agent handles large PRs through a compression strategy, and its behavior can be changed through configuration files such as pr_agent/settings/configuration.toml.
- /describe writes a PR description.
- /review gives a review.
- /improve suggests code improvements.
- /ask answers a question about the PR.
- /similar_issue runs on an issue to find similar issues.
/describe
/review
/improve
/ask "What does this PR change?"Change the AI model and check the output
PR Agent can use OpenAI GPT, Anthropic Claude, Google Gemini, DeepSeek, Mistral and any model reachable through LiteLLM, including Ollama. The README points to a Changing a model page for setup details.
The README is clear that LLM suggestions can be wrong, so treat the output as a first pass and check it yourself before merging.
- See the Changing a model page at docs.pr-agent.ai for model configuration.
- Review each suggestion before acting on it.
What people use it for
- Get a first-pass review on each new pull request before a human reviewer looks at it.
- Generate a PR description with /describe.
- Ask free-text questions about what a PR changes with /ask.
- Find similar issues in a repository with /similar_issue on an issue.
- Use a self-hosted setup to keep code and infrastructure under your own control.
Frequently asked questions
Is PR Agent free?
PR Agent is released under the MIT licence, according to the README. You still need an API key for an AI model provider, and the README notes that model usage is between you and that provider. The README also says this project is not the Qodo free tier.
What are the requirements for PR Agent?
The README lists Python and an API key for an AI model provider such as OpenAI as prerequisites. For GitHub Actions, you also need a workflow file and repository secrets.
Which git providers does PR Agent support?
The README names GitHub, GitLab, Bitbucket, Azure DevOps and Gitea. Support is limited to those named in the README, so check the supported platforms page before you rely on another provider.
Can PR Agent use a model other than OpenAI?
Yes. The README says PR Agent can use Anthropic Claude, Google Gemini, DeepSeek, Mistral and any model reachable through LiteLLM, including Ollama. See the Changing a model page in the docs for setup.
Is PR Agent the same as Qodo Merge?
No. The README says this repository is the open-source PR Agent project and is not the Qodo offering for open-source projects. It says the project was donated by Qodo and is now community-maintained.
Why does /help_docs not work?
The README says /help_docs is temporarily disabled since v0.36.1 while a credential-exposure issue is fixed. It links to issue #2445 for status.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
PR Agent suits teams and developers who want automated first-pass reviews, control over their model provider, and a self-hosted setup. It is a poor fit if you want a managed service with no configuration, or if you need review output you can trust without checking it, since the README warns that LLM suggestions can be wrong.
Install options & downloads