Skip to content

n-devs/ai-code-review

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AI Code Review Action

Automated PR code review powered by AI — supports GitHub Models, GitHub Copilot, OpenAI, Anthropic, Google Gemini, xAI, OpenRouter, Ollama, Azure, AWS, and more.

Quick Start

Zero-config setup using GitHub Models — works with GITHUB_TOKEN, no extra secrets needed:

name: AI Code Review
on:
  pull_request:
    types: [opened, synchronize, reopened]

permissions:
  pull-requests: write
  contents: read
  models: read

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: n-devs/ai-code-review@v2
        with:
          gh_pat: ${{ secrets.GITHUB_TOKEN }}
          repo: ${{ github.repository }}
          pr_number: ${{ github.event.pull_request.number }}
          api_key: ${{ secrets.GITHUB_TOKEN }}

Inputs

Input Required Default Description
gh_pat GitHub PAT for GitHub API (fetching diff, posting comments)
repo Repository in owner/repo format
pr_number Pull request number to review
api_key API key for the provider. For github-models: use GITHUB_TOKEN. For copilot: use a personal PAT with Copilot subscription
provider github-azure-models AI provider shorthand (see Providers)
model gpt-4o Model name (see Providers for naming convention per provider)
title AI Code Review Title shown in the PR comment header
api_url Full endpoint URL — overrides provider + api_type defaults
api_type chat API format: chat, responses, or messages
max_tokens 2048 Maximum tokens in AI response
max_diff_chars 10000 Maximum characters of diff sent to AI
language English Language for the review response

Providers

provider api_type default Base URL Auth Model naming
github-azure-models (default) chat https://models.inference.ai.azure.com GITHUB_TOKEN Plain name, e.g. gpt-4o
github-models chat https://models.github.ai/inference GITHUB_TOKEN Publisher-prefixed, e.g. openai/gpt-4o-mini
copilot chat https://api.githubcopilot.com Personal PAT with Copilot subscription Plain name, e.g. gpt-4o
openai chat https://api.openai.com/v1 API key Plain name, e.g. gpt-4o
anthropic messages https://api.anthropic.com/v1 API key e.g. claude-3-5-sonnet-20241022
openrouter chat https://openrouter.ai/api/v1 API key e.g. meta-llama/llama-3.3-70b-instruct
ollama chat http://localhost:11434/v1 e.g. llama3
xai chat https://api.x.ai/v1 API key (Grok) e.g. grok-3
zai chat https://api.z.ai/api/coding/paas/v4 API key (GLM) provider-specific
google chat https://generativelanguage.googleapis.com/v1beta/openai API key e.g. gemini-2.0-flash
azure chat ⚠️ requires api_url api-key header your deployment name
aws chat ⚠️ requires api_url API key provider-specific
custom chat ⚠️ requires api_url API key provider-specific

Note: copilot provider exchanges a personal PAT for a short-lived session token automatically. GITHUB_TOKEN from GitHub Actions will not work for Copilot — use github-azure-models/github-models instead for zero-config setups.

GitHub Models has two provider shorthands:

  • github-azure-models (default) uses the legacy models.inference.ai.azure.com endpoint with plain model names (gpt-4o).
  • github-models uses the current models.github.ai/inference endpoint documented in GitHub's Quickstart, which requires publisher-prefixed model names (openai/gpt-4o-mini, openai/gpt-5-mini, etc.).

If github-azure-models ever stops responding, switch to provider: github-models with a publisher-prefixed model.

API Types

api_type Path appended Compatible with
chat /chat/completions GitHub Models, Copilot, OpenAI, OpenRouter, Ollama, xAI, Google, Azure
responses /responses OpenAI Responses API
messages /messages Anthropic Claude
text /completions Legacy completions endpoint

Examples

GitHub Models (default — zero config)

- uses: n-devs/ai-code-review@v2
  with:
    gh_pat: ${{ secrets.GITHUB_TOKEN }}
    repo: ${{ github.repository }}
    pr_number: ${{ github.event.pull_request.number }}
    api_key: ${{ secrets.GITHUB_TOKEN }}

GitHub Models (current endpoint, publisher-prefixed model)

- uses: n-devs/ai-code-review@v2
  with:
    gh_pat: ${{ secrets.GITHUB_TOKEN }}
    repo: ${{ github.repository }}
    pr_number: ${{ github.event.pull_request.number }}
    provider: github-models
    api_key: ${{ secrets.GITHUB_TOKEN }}
    model: openai/gpt-4o-mini

GitHub Copilot

Requires a personal PAT with Copilot subscription stored as COPILOT_PAT secret.

- uses: n-devs/ai-code-review@v2
  with:
    gh_pat: ${{ secrets.GITHUB_TOKEN }}
    repo: ${{ github.repository }}
    pr_number: ${{ github.event.pull_request.number }}
    provider: copilot
    api_key: ${{ secrets.COPILOT_PAT }}
    model: gpt-4o

OpenAI GPT-4o

- uses: n-devs/ai-code-review@v2
  with:
    gh_pat: ${{ secrets.GITHUB_TOKEN }}
    repo: ${{ github.repository }}
    pr_number: ${{ github.event.pull_request.number }}
    provider: openai
    api_key: ${{ secrets.OPENAI_API_KEY }}
    model: gpt-4o

Anthropic Claude

- uses: n-devs/ai-code-review@v2
  with:
    gh_pat: ${{ secrets.GITHUB_TOKEN }}
    repo: ${{ github.repository }}
    pr_number: ${{ github.event.pull_request.number }}
    provider: anthropic
    api_key: ${{ secrets.ANTHROPIC_API_KEY }}
    model: claude-3-5-sonnet-20241022
    max_tokens: "8192"

Google Gemini

- uses: n-devs/ai-code-review@v2
  with:
    gh_pat: ${{ secrets.GITHUB_TOKEN }}
    repo: ${{ github.repository }}
    pr_number: ${{ github.event.pull_request.number }}
    provider: google
    api_key: ${{ secrets.GOOGLE_API_KEY }}
    model: gemini-2.0-flash

xAI Grok

- uses: n-devs/ai-code-review@v2
  with:
    gh_pat: ${{ secrets.GITHUB_TOKEN }}
    repo: ${{ github.repository }}
    pr_number: ${{ github.event.pull_request.number }}
    provider: xai
    api_key: ${{ secrets.XAI_API_KEY }}
    model: grok-3

OpenRouter

- uses: n-devs/ai-code-review@v2
  with:
    gh_pat: ${{ secrets.GITHUB_TOKEN }}
    repo: ${{ github.repository }}
    pr_number: ${{ github.event.pull_request.number }}
    provider: openrouter
    api_key: ${{ secrets.OPENROUTER_API_KEY }}
    model: meta-llama/llama-3.3-70b-instruct

Ollama (self-hosted)

- uses: n-devs/ai-code-review@v2
  with:
    gh_pat: ${{ secrets.GITHUB_TOKEN }}
    repo: ${{ github.repository }}
    pr_number: ${{ github.event.pull_request.number }}
    provider: ollama
    api_key: ""
    api_url: http://my-server:11434/v1/chat/completions
    model: llama3

Azure OpenAI

- uses: n-devs/ai-code-review@v2
  with:
    gh_pat: ${{ secrets.GITHUB_TOKEN }}
    repo: ${{ github.repository }}
    pr_number: ${{ github.event.pull_request.number }}
    provider: azure
    api_key: ${{ secrets.AZURE_OPENAI_API_KEY }}
    api_url: https://my-resource.openai.azure.com/openai/deployments/gpt-4o/chat/completions?api-version=2024-02-01
    model: gpt-4o

OpenAI Responses API

- uses: n-devs/ai-code-review@v2
  with:
    gh_pat: ${{ secrets.GITHUB_TOKEN }}
    repo: ${{ github.repository }}
    pr_number: ${{ github.event.pull_request.number }}
    provider: openai
    api_key: ${{ secrets.OPENAI_API_KEY }}
    api_type: responses
    model: gpt-4o

Custom Provider

- uses: n-devs/ai-code-review@v2
  with:
    gh_pat: ${{ secrets.GITHUB_TOKEN }}
    repo: ${{ github.repository }}
    pr_number: ${{ github.event.pull_request.number }}
    provider: custom
    api_key: ${{ secrets.MY_API_KEY }}
    api_url: https://my-llm-proxy.internal/v1/chat/completions
    model: my-model

Review in Thai

- uses: n-devs/ai-code-review@v2
  with:
    gh_pat: ${{ secrets.GITHUB_TOKEN }}
    repo: ${{ github.repository }}
    pr_number: ${{ github.event.pull_request.number }}
    api_key: ${{ secrets.GITHUB_TOKEN }}
    language: Thai

Build

npm install
npm run build   # outputs dist/index.js via @vercel/ncc
npm test        # runs unit tests via vitest

Releases

Packages

Used by

Contributors

Languages