Inicio Rápido¶
Pon en marcha AI Code Reviewer en 5 minutos en GitHub o GitLab.
Paso 1: Elige tu proveedor LLM y obtén una clave API¶
AI Reviewer soporta múltiples proveedores LLM. Elige uno (o usa ambos para fallback):
- Ve a Google AI Studio
- Inicia sesión con tu cuenta de Google
- Haz clic en "Get API key" → "Create API key"
- Copia la clave (comienza con
AIza...)
Nivel gratuito
Gemini API tiene un nivel gratuito: 15 solicitudes por minuto, suficiente para la mayoría de los equipos de 4-8 desarrolladores.
- Ve a Mistral Console
- Regístrate o inicia sesión
- Navega a API Keys → Create new key
- Copia la clave (comienza con
sk-...)
Nivel gratuito
Mistral ofrece un nivel gratuito para experimentación. Después de registrarte, obtienes créditos API gratuitos para probar todos los modelos. Límites actuales: Mistral Pricing.
Codestral gratuito
Codestral (un modelo especializado en código) tiene su propio nivel gratuito con endpoint y clave separados:
- Vaya a codestral.mistral.ai
- Genere una clave API de Codestral
- Configure
AI_REVIEWER_MISTRAL_API_URL=https://codestral.mistral.ai - Configure
AI_REVIEWER_MISTRAL_MODEL=codestral-latest
Esta clave funciona solo con codestral-latest en el endpoint de Codestral.
Obtén ambas claves usando las instrucciones anteriores. Esto te da:
- Mistral como modelo primario (ej.
mistral-large-latest) - Google Gemini como fallback automático si Mistral no está disponible
Esta es la configuración más confiable para uso en producción.
Guarda la clave
Las claves API solo se muestran una vez. Guárdalas en un lugar seguro.
Paso 2: Añadir secretos al repositorio¶
Ruta: Repository → Settings → Secrets and variables → Actions → New repository secret
| Name | Value |
|---|---|
AI_REVIEWER_GOOGLE_API_KEY |
Tu clave Gemini (AIza...) |
| Name | Value |
|---|---|
AI_REVIEWER_MISTRAL_API_KEY |
Tu clave Mistral (sk-...) |
| Name | Value |
|---|---|
AI_REVIEWER_MISTRAL_API_KEY |
Tu clave Mistral (sk-...) |
AI_REVIEWER_GOOGLE_API_KEY |
Tu clave Gemini (AIza...) |
Haz clic en "Add secret" para cada uno.
Instrucciones detalladas con capturas de pantalla
- Abre tu repositorio en GitHub
- Haz clic en Settings (engranaje en el menú superior)
- En el menú izquierdo, busca Secrets and variables → Actions
- Haz clic en el botón verde New repository secret
- Ingresa el nombre y pega tu clave
- Haz clic en Add secret
- Repite para cada secreto
Para GitLab también necesitas un token de GitLab para publicar comentarios.
Paso 2a: Crear un token de GitLab¶
Ruta: Avatar de usuario → Edit profile → Access Tokens
| Campo | Valor |
|---|---|
| Token name | ai-reviewer |
| Expiration date | Elige una fecha (máx. 1 año) |
| Scopes | api |
Haz clic en "Create personal access token" → Copia el token (¡solo se muestra una vez!)
Los comentarios aparecerán bajo tu nombre de usuario
Un Personal Access Token está vinculado a tu cuenta. Todos los comentarios de revisión se publicarán en tu nombre.
Se requieren permisos de Maintainer
Para crear un Project Access Token necesitas el rol Maintainer u Owner en el proyecto.
Ruta: Project → Settings → Access Tokens
| Campo | Valor |
|---|---|
| Token name | ai-reviewer |
| Expiration date | Elige una fecha (máx. 1 año) |
| Role | Developer |
| Scopes | api |
Haz clic en "Create project access token" → Copia el token (¡solo se muestra una vez!)
Paso 2b: Añadir variables en CI/CD¶
Ruta: Project → Settings → CI/CD → Variables
| Key | Value | Flags |
|---|---|---|
AI_REVIEWER_GOOGLE_API_KEY |
Tu clave Gemini | |
AI_REVIEWER_GITLAB_TOKEN |
Token del paso 2a |
| Key | Value | Flags |
|---|---|---|
AI_REVIEWER_MISTRAL_API_KEY |
Tu clave Mistral | |
AI_REVIEWER_GITLAB_TOKEN |
Token del paso 2a |
| Key | Value | Flags |
|---|---|---|
AI_REVIEWER_MISTRAL_API_KEY |
Tu clave Mistral | |
AI_REVIEWER_GOOGLE_API_KEY |
Tu clave Gemini | |
AI_REVIEWER_GITLAB_TOKEN |
Token del paso 2a |
¡Desmarca «Protected»!
Por defecto, GitLab marca las nuevas variables como Protected. Las variables Protected solo están disponibles en ramas protegidas (ej. main), pero los pipelines de MR se ejecutan en ramas de origen no protegidas — la variable estará vacía y obtendrás 401 Unauthorized.
CI_JOB_TOKEN no funciona
El CI_JOB_TOKEN automático de GitLab no puede publicar comentarios en Merge Requests.
Debes crear un Personal Access Token (o Project Access Token en Premium+).
Paso 3: Añadir AI Review al CI¶
Crea el archivo .github/workflows/ai-review.yml:
name: AI Code Review
on:
pull_request:
types: [opened, synchronize, reopened]
concurrency:
group: ai-review-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
review:
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == github.repository
permissions:
contents: read
pull-requests: write
steps:
- uses: KonstZiv/ai-code-reviewer@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
google_api_key: ${{ secrets.AI_REVIEWER_GOOGLE_API_KEY }}
name: AI Code Review
on:
pull_request:
types: [opened, synchronize, reopened]
concurrency:
group: ai-review-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
review:
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == github.repository
permissions:
contents: read
pull-requests: write
steps:
- uses: KonstZiv/ai-code-reviewer@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
mistral_api_key: ${{ secrets.AI_REVIEWER_MISTRAL_API_KEY }}
llm_provider: mistral
name: AI Code Review
on:
pull_request:
types: [opened, synchronize, reopened]
concurrency:
group: ai-review-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
review:
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == github.repository
permissions:
contents: read
pull-requests: write
steps:
- uses: KonstZiv/ai-code-reviewer@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
mistral_api_key: ${{ secrets.AI_REVIEWER_MISTRAL_API_KEY }}
google_api_key: ${{ secrets.AI_REVIEWER_GOOGLE_API_KEY }}
llm_provider: mistral
llm_fallback_provider: google
name: AI Code Review
on:
pull_request:
types: [opened, synchronize, reopened]
concurrency:
group: ai-review-${{ github.event.pull_request.number }}
cancel-in-progress: true
jobs:
review:
runs-on: ubuntu-latest
if: github.event.pull_request.head.repo.full_name == github.repository
permissions:
contents: read
pull-requests: write
steps:
- uses: KonstZiv/ai-code-reviewer@v1
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
mistral_api_key: ${{ secrets.AI_REVIEWER_MISTRAL_API_KEY }}
llm_provider: mistral
mistral_model: codestral-latest
mistral_api_url: https://codestral.mistral.ai
Clave de Codestral
Use la clave de codestral.mistral.ai, no la clave API regular de Mistral.
Sobre GITHUB_TOKEN
secrets.GITHUB_TOKEN es un token automático que GitHub crea para cada workflow run. No necesitas añadirlo manualmente a los secretos — ya está disponible.
Crea o actualiza .gitlab-ci.yml:
stages:
- review
ai-review:
image: ghcr.io/konstziv/ai-code-reviewer:1
stage: review
script:
- ai-review
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
allow_failure: true
Las variables CI/CD AI_REVIEWER_GOOGLE_API_KEY y AI_REVIEWER_GITLAB_TOKEN del paso 2b están disponibles automáticamente.
stages:
- review
ai-review:
image: ghcr.io/konstziv/ai-code-reviewer:1
stage: review
variables:
AI_REVIEWER_LLM_PROVIDER: mistral
script:
- ai-review
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
allow_failure: true
Las variables CI/CD AI_REVIEWER_MISTRAL_API_KEY y AI_REVIEWER_GITLAB_TOKEN del paso 2b están disponibles automáticamente.
stages:
- review
ai-review:
image: ghcr.io/konstziv/ai-code-reviewer:1
stage: review
variables:
AI_REVIEWER_LLM_PROVIDER: mistral
AI_REVIEWER_LLM_FALLBACK_PROVIDER: google
script:
- ai-review
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
allow_failure: true
Las tres variables CI/CD (AI_REVIEWER_MISTRAL_API_KEY, AI_REVIEWER_GOOGLE_API_KEY, AI_REVIEWER_GITLAB_TOKEN) del paso 2b están disponibles automáticamente.
stages:
- review
ai-review:
image: ghcr.io/konstziv/ai-code-reviewer:1
stage: review
variables:
AI_REVIEWER_LLM_PROVIDER: mistral
AI_REVIEWER_MISTRAL_MODEL: codestral-latest
AI_REVIEWER_MISTRAL_API_URL: https://codestral.mistral.ai
script:
- ai-review
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
allow_failure: true
Las variables CI/CD AI_REVIEWER_MISTRAL_API_KEY (use la clave de Codestral) y AI_REVIEWER_GITLAB_TOKEN del Paso 2b están disponibles automáticamente.
Paso 4: Verificar resultado¶
Ahora AI Review se ejecutará automáticamente cuando:
| Plataforma | Evento |
|---|---|
| GitHub | Crear PR, nuevos commits en PR, reopening PR |
| GitLab | Crear MR, nuevos commits en MR |
Qué verás¶
Después de que el job de CI termine, en el PR/MR aparecerán:
- Comentarios inline — vinculados a líneas de código específicas
- Botón "Apply suggestion" — para aplicar correcciones rápidamente (GitHub)
- Comentario Summary — resumen general con métricas
Cada comentario contiene:
/
/
Badge de severidad
- Descripción del problema
- Sugerencia de corrección
- Sección colapsable "¿Por qué importa esto?"
En el pie del comentario se muestra qué modelo y proveedor se utilizó:
Model: Google / gemini-2.5-flash | Tokens: 1,234 | Latency: 2.3s | Est. cost: $0.0012
Solución de Problemas¶
¿No aparece la revisión?¶
Verifica la lista:
- ¿Clave API añadida como secreto? (
AI_REVIEWER_GOOGLE_API_KEYoAI_REVIEWER_MISTRAL_API_KEY) - ¿
llm_providerconfigurado correctamente si usas Mistral? (predeterminado esgoogle) - ¿
github_tokenpasado explícitamente? (para GitHub) - Para GitLab: ¿
AI_REVIEWER_GITLAB_TOKENconfigurado con un Personal Access Token? - ¿El job de CI terminó exitosamente? (revisa logs)
- Para GitHub: ¿tiene
permissions: pull-requests: write? - Para PRs de forks: los secretos no están disponibles — comportamiento esperado
¿Rate limit?¶
- Gemini free tier: 15 solicitudes por minuto
- Mistral free tier: límites actuales en Mistral Pricing
Espera un minuto e intenta de nuevo, o configura un proveedor de fallback.
Todos los problemas y soluciones →
¿Qué sigue?¶
| Tarea | Documento |
|---|---|
| Configurar idioma de respuestas | Configuración |
| Configuración avanzada de proveedores LLM | Configuración → LLM |
| Cambiar modelos sin modificar código | GitHub → Configuración mediante Variables |
| Configuración avanzada de GitHub | Guía de GitHub |
| Configuración avanzada de GitLab | Guía de GitLab |
| Ejemplos de workflows | Ejemplos |