IzziAPI
TutorialApr 11, 20267 min read

Build an AI PR Reviewer with GitHub Actions

Automate code reviews with Claude AI in your GitHub CI/CD pipeline. Catch bugs, security issues, and style problems automatically.

Izzi API Team
Engineering & DevRel
github-actionscode-reviewci-cdautomationizzi-api
Build an AI PR Reviewer with GitHub Actions

Automated code review in 20 minutes

This GitHub Action reviews every pull request with Claude AI. It catches security vulnerabilities, performance issues, and code smell β€” before any human reviewer sees the code. Cost: ~$0.01 per PR on Izzi API.

Step 1: Create the GitHub Action

YAML
# .github/workflows/ai-review.yml
name: AI Code Review
on:
  pull_request:
    types: [opened, synchronize]

jobs:
  review:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          fetch-depth: 0
      
      - name: Get diff
        id: diff
        run: |
          DIFF=$(git diff origin/main...HEAD -- '*.ts' '*.tsx' '*.py' '*.js')
          echo "diff<<EOF" >> $GITHUB_OUTPUT
          echo "$DIFF" >> $GITHUB_OUTPUT
          echo "EOF" >> $GITHUB_OUTPUT
      
      - name: AI Review
        uses: actions/github-script@v7
        env:
          IZZI_API_KEY: ${{ secrets.IZZI_API_KEY }}
        with:
          script: |
            const diff = `${{ steps.diff.outputs.diff }}`;
            if (!diff.trim()) return;
            
            const response = await fetch('https://api.izziapi.com/v1/chat/completions', {
              method: 'POST',
              headers: {
                'Content-Type': 'application/json',
                'Authorization': `Bearer ${process.env.IZZI_API_KEY}`,
              },
              body: JSON.stringify({
                model: 'claude-sonnet-4-20250514',
                messages: [{
                  role: 'user',
                  content: `Review this PR diff. Focus on:
1. Security vulnerabilities (critical)
2. Bugs and logic errors (high)
3. Performance issues (medium)
4. Code style improvements (low)

Format: bullet list with severity and file:line.

${diff.substring(0, 15000)}`
                }],
                max_tokens: 2000,
              }),
            });
            
            const data = await response.json();
            const review = data.choices[0].message.content;
            
            await github.rest.issues.createComment({
              owner: context.repo.owner,
              repo: context.repo.name,
              issue_number: context.issue.number,
              body: `## πŸ€– AI Code Review\n\n${review}\n\n---\n*Powered by Izzi API + Claude Sonnet 4*`,
            });

Step 2: Add your API key to GitHub Secrets

  1. Go to your repo β†’ Settings β†’ Secrets and variables β†’ Actions
  2. Click "New repository secret"
  3. Name: IZZI_API_KEY
  4. Value: izzi-YOUR_KEY_HERE

Cost analysis

PRs per monthAvg diff sizeCost (Izzi API)
50500 lines$0.63
200500 lines$2.52
500500 lines$6.30

What's next

Ready to start building?

Access 38+ AI models through a single API. Free tier available β€” no credit card required.

MORE

Related articles