<p align="center">
<img alt="lgtm-logo" width="150" src="./assets/lgtm-large.png">
</p>
# lgtm-ai


[](https://github.com/astral-sh/ruff)
[](https://pypi.org/project/lgtm-ai/)
[](LICENSE)
---
lgtm-ai is your AI-powered code review companion. It generates code reviews using your favorite LLMs and helps human reviewers with detailed, context-aware reviewer guides. Supports GitHub, GitLab, and major AI models including GPT-4, Claude, Gemini, and more.
**Table of Contents**
- [Quick Usage](#quick-usage)
- [Review](#review)
- [Reviewer Guide](#reviewer-guide)
- [Installation](#installation)
- [How it works](#how-it-works)
- [Review scores and comment categories](#review-scores-and-comment-categories)
- [Supported Code Repository Services](#supported-code-repository-services)
- [Supported AI models](#supported-ai-models)
- [OpenAI](#openai)
- [Google Gemini](#google-gemini)
- [Anthropic's Claude](#anthropics-claude)
- [Mistral AI](#mistral-ai)
- [DeepSeek](#deepseek)
- [Local models](#local-models)
- [CI/CD Integration](#cicd-integration)
- [Configuration](#configuration)
- [Configuration file](#configuration-file)
- [Contributing](#contributing)
- [Running the project](#running-the-project)
- [Managing requirements](#managing-requirements)
- [Commit messages](#commit-messages)
- [Contributors ✨](#contributors-)
## Quick Usage
### Review
```sh
lgtm review --pr-url "https://gitlab.com/your-repo/-/merge-requests/42" \
--ai-api-key $OPENAI_API_KEY \
--git-api-key $GITLAB_TOKEN \
--model gpt-4.1 \
--publish
```
This will generate a **review** like this one:
<img src="./assets/review.png" alt="lgtm-review" height="250"/>
<br/>
<img src="./assets/review-comment.png" alt="lgtm-review-comment" height="250"/>
### Reviewer Guide
```sh
lgtm guide --pr-url "https://gitlab.com/your-repo/-/merge-requests/42" \
--ai-api-key $OPENAI_API_KEY \
--git-api-key $GITLAB_TOKEN \
--model gpt-4.1 \
--publish
```
This will generate a **reviewer guide** like this one:
<img src="./assets/reviewer-guide.png" alt="lgtm-review-guide" height="250"/>
## Installation
```sh
pip install lgtm-ai
```
Or you can use the official Docker image:
```sh
docker pull elementsinteractive/lgtm-ai
```
## How it works
lgtm reads the given pull request and feeds it to several AI agents to generate a code review or a reviewer guide. The philosophy of lgtm is to keep the models out of the picture and totally configurable, so that you can choose which model to use based on pricing, security, data privacy, or whatever is important to you.
If instructed (with the option `--publish`), lgtm will publish the review or guide to the pull request page as comments.
### Review scores and comment categories
Reviews generated by lgtm will be assigned a **score**, using the following scale:
| Score | Description |
| ------ | --- |
| LGTM 👍 | The PR is generally ready to be merged. |
| Nitpicks 🤓 | There are some minor issues, but the PR is almost ready to be merged. |
| Needs Work 🔧 | There are some issues with the PR, and it is not ready to be merged. The approach is generally good, the fundamental structure is there, but there are some issues that need to be fixed. |
| Needs a Lot of Work 🚨 | Issues are major, overarching, and/or numerous. However, the approach taken is not necessarily wrong. |
| Abandon ❌ | The approach taken is wrong, and the author needs to start from scratch. The PR is not ready to be merged as is at all. |
For each review, lgtm may create several inline comments, pointing out specific issues within the PR. These comments belong to a **category** and have a **severity**. You can configure which categories you want lgtm to take a look at (see the [configuration section below](./README.md#configuration-file)). The available categories are:
| Category | Description |
| ------- | ----------- |
| Correctness 🎯 | Does the code behave as intended? Identifies logical errors, bugs, incorrect algorithms, broken functionality, or deviations from requirements. |
| Quality ✨ | Is the code clean, readable, and maintainable? Evaluates naming, structure, modularity, and adherence to clean code principles (e.g., SOLID, DRY, KISS). |
| Testing 🧪 | Are there sufficient and appropriate tests? Includes checking for meaningful test coverage, especially for edge cases and critical paths. Are tests isolated, reliable, and aligned with the behavior being verified? |
| Security 🔒 | Does the code follow secure programming practices? Looks for common vulnerabilities such as injection attacks, insecure data handling, improper access control, hardcoded credentials, or lack of input validation. |
There are three available severities for comments:
- LOW 🔵
- MEDIUM 🟡
- HIGH 🔴
### Supported Code Repository Services
lgtm aims to work with as many services as possible, and that includes remote repository providers. At the moment, lgtm supports:
- [GitLab](https://gitlab.com) (only gitlab.com, not self-hosted)
- [GitHub](https://github.com)
lgtm will autodetect the url of the pull request passed to `--pr-url` automatically.
### Supported AI models
lgtm supports several AI models so you can hook up your preferred LLM to perform reviews for you.
This is the full list of supported models:
#### OpenAI
Check out the OpenAI platform page to see [all available models provided by OpenAI](https://platform.openai.com/docs/overview).
To use OpenAI LLMs, you need to provide lgtm with an API Key, which can be generated in the [OpenAI platform page for your project, or your user](https://platform.openai.com/api-keys).
<details>
<summary>Supported OpenAI models</summary>
These are the main supported models, though the CLI may support additional ones due to the use of [pydantic-ai](https://ai.pydantic.dev).
| Model name |
| -------- |
| gpt-5 |
| gpt-5-mini |
| gpt-4.1 |
| gpt-4.1-mini |
| gpt-4.1-nano |
| gpt-4o * |
| gpt-4o-mini |
| o4-mini |
| o3-mini |
| o3 |
| o1-preview |
| o1-mini |
| o1 |
| gpt-4-turbo |
| gpt-4 |
| gpt-3.5-turbo |
| chatgpt-4o-latest |
</details>
#### Google Gemini
Check out the [Gemini developer docs](https://ai.google.dev/gemini-api/docs/models) to see all models provided by Google.
To use Gemini LLMs, you need to provide lgtm an API Key, which can be generated [here](https://aistudio.google.com/apikey).
These are the main supported models, though the CLI may support additional ones due to the use of [pydantic-ai](https://ai.pydantic.dev). Gemini timestamps models, so be sure to always use the latest model of each family, if possible.
For Gemini models exclusively, you can provide a wildcard at the end of the model name and lgtm will attempt to select the latest model (e.g., `gemini-2.5-pro*`)
<details>
<summary>Supported Google's Gemini models</summary>
| Model name |
| ----------- |
| gemini-2.5-pro |
| gemini-2.5-pro-preview-06-05 |
| gemini-2.5-pro-preview-05-06 |
| gemini-2.5-flash |
| gemini-2.0-pro-exp-02-05 |
| gemini-2.0-flash |
| gemini-1.5-pro |
| gemini-1.5-flash |
</details>
#### Anthropic's Claude
Check out [Anthropic documentation](https://docs.anthropic.com/en/docs/about-claude/models/all-models) to see which models they provide. lgtm works with a subset of Claude models. To use Anthropic LLMs, you need to provide lgtm with an API Key, which can be generated from the [Anthropic Console](https://console.anthropic.com/dashboard).
<details>
<summary>Supported Anthropic models</summary>
These are the main supported models, though the CLI may support additional ones due to the use of [pydantic-ai](https://ai.pydantic.dev).
| Model name |
| ---------------------------- |
| claude-sonnet-4-0 |
| claude-3-7-sonnet-latest |
| claude-3-5-sonnet-latest |
| claude-3-5-haiku-latest |
| claude-3-opus-latest |
</details>
#### Mistral AI
Check out the [Mistral documentation](https://docs.mistral.ai/getting-started/models/models_overview/) to see all models provided by Mistral.
To use Mistral LLMs, you need to provide lgtm with an API Key, which can be generated from Mistral's [Le Platforme](https://console.mistral.ai/api-keys).
<details>
<summary>Supported Mistral AI models</summary>
These are the main supported models, though the CLI may support additional ones due to the use of [pydantic-ai](https://ai.pydantic.dev).
| Model name |
| ------------------ |
| mistral-large-latest |
| mistral-small |
| codestrallatest |
</details>
#### DeepSeek
Check out the [DeepSeek documentation](https://api-docs.deepseek.com/quick_start/pricing) to see all models provided by DeepSeek.
At the moment, lgtm only supports DeepSeek from `https://api.deepseek.com`: other providers and custom URLs are not supported. However, this is in our roadmap!
To get an API key for DeepSeek, create one at [DeepSeek Platform](https://platform.deepseek.com/usage).
<details>
<summary>Supported DeepSeek models</summary>
| Model name |
| ----------- |
| deepseek-chat |
| deepseek-reasoner |
</details>
#### Local models
You can run lgtm against a model available at a custom url (say, models running with [ollama](https://ollama.com) at http://localhost:11434/v1). These models need to be compatible with OpenAI. In that case, you need to pass the option `--model-url` (and you can choose to skip the option `--ai-api-token`). Check out the [pydantic-ai documentation](https://ai.pydantic.dev/models/openai/#openai-responses-api) to see more information about how lgtm interacts with these models.
```sh
lgtm review \
--pr-url https://github.com/group/repo/pull/1 \
--model llama3.2 \
--model-url http://localhost:11434/v1 \
...
```
### CI/CD Integration
lgtm is meant to be integrated into your CI/CD pipeline, so that PR authors can choose to request reviews by running the necessary pipeline step.
For GitLab, you can use this .gitlab-ci.yml step as inspiration:
```yaml
lgtm-review:
image:
name: docker.io/elementsinteractive/lgtm-ai
entrypoint: [""]
stage: ai-review
needs: []
rules:
- if: $CI_MERGE_REQUEST_ID
when: manual
script:
- lgtm review --pr-url ${MR_URL} --git-api-key ${LGTM_GIT_API_KEY} --ai-api-key ${LGTM_AI_API_KEY} -v
variables:
MR_URL: "${CI_PROJECT_URL}/-/merge_requests/${CI_MERGE_REQUEST_IID}"
```
For GitHub, we plan to provide a GitHub action soon. In the meantime, check out this repo's [lgtm workflow](./.github/workflows/lgtm.yml), with which you can trigger reviews in PRs by commenting `/lgtm review`.
### Configuration
You can customize how lgtm works by passing cli arguments to it on invocation, or by using the *lgtm configuration file*.
#### Configuration file
lgtm uses a `.toml` file to configure how it works. It will autodetect a `lgtm.toml` file in the current directory, or you can pass a specific file path with the CLI option `--config <path>`. These are the available options at the moment:
- **technologies**: You can specify, as a list of free strings, which technologies lgtm specializes in. This can be helpful for directing the reviewer towards specific technologies. By default, lgtm won't assume any technology and will just review the PR considering itself an "expert" in it.
- **categories**: lgtm will, by default, evaluate several areas of the given PR (`Quality`, `Correctness`, `Testing`, and `Security`). You can choose any subset of these (e.g.: if you are only interested in `Correctness`, you can configure `categories` so that lgtm does not evaluate the other missing areas).
- **model**: Choose which AI model you want lgtm to use.
- **model_url**: When not using one of the specific supported models from the providers mentioned above, you can pass a custom url where the model is deployed.
- **exclude**: Instruct lgtm to ignore certain files. This is important to reduce noise in reviews, but also to reduce the amount of tokens used for each review (and to avoid running into token limits). You can specify file patterns (`exclude = ["*.md", "package-lock.json"]`)
- **output_format**: Format of the terminal output of lgtm. Can be `pretty` (default), `json`, and `markdown`.
- **silent**: Do not print the review in the terminal.
- **publish**: If `true`, it will post the review as comments on the PR page.
- **ai_api_key**: API key to call the selected AI model. Can be given as a CLI argument, or as an environment variable (`LGTM_AI_API_KEY`).
- **git_api_key**: API key to post the review in the source system of the PR. Can be given as a CLI argument, or as an environment variable (`LGTM_GIT_API_KEY`). This is required to not be empty if using a non-local model.
- **ai_retries**: How many times to retry calls to the LLM when they do not succeed. By default, this is set to 1 (no retries at all).
- **additional_context**: TOML array of extra context to send to the LLM. It supports setting the context directly in the `context` field, passing a relative file path so that lgtm downloads it from the repository, or passing any URL from which to download the context. Each element of the array must contain `prompt`, and either `context` (directly injecting context) or `file_url` (for directing lgtm to download it from there).
**Example `lgtm.toml`:**
```toml
technologies = ["Django", "Python"]
categories = ["Correctness", "Quality", "Testing", "Security"]
exclude = ["*.md"]
model = "gpt-4.1"
silent = false
publish = true
ai_retries = 1
[[additional_context]]
prompt = "These are the development guidelines for the team, ensure the PR follows them"
file_url = "https://my.domain.com/dev-guidelines.md"
[[additional_context]]
prompt = "CI pipeline for the repo. Do not report issues that this pipeline would otherwise catch"
file_url = ".github/workflows/pr.yml"
[[additional_context]]
prompt = "Consider these points when making your review"
context = '''
- We avoid using libraries and rely mostly on the stdlib.
- We follow the newest syntax available for Python (3.13).
'''
```
Alternatively, lgtm also supports [pyproject.toml](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/) files, you just need to nest the options inside `[tool.lgtm]`.
When it comes to preference for selecting options, lgtm follows this preference order:
`CLI options` > `lgtm.toml` > `pyproject.toml`
## Contributing
### Running the project
This project uses [`just`](https://github.com/casey/just) recipes to do all the basic operations (testing the package, formatting the code, etc.).
Installation:
```sh
brew install just
# or
snap install --edge --classic just
```
It requires [poetry](https://python-poetry.org/docs/#installation).
These are the available commands for the justfile:
```
Available recipes:
help # Shows list of recipes.
venv # Generate the virtual environment.
clean # Cleans all artifacts generated while running this project, including the virtualenv.
test *test-args='' # Runs the tests with the specified arguments (any path or pytest argument).
t *test-args='' # alias for `test`
test-all # Runs all tests including coverage report.
format # Format all code in the project.
lint # Lint all code in the project.
pre-commit *precommit-args # Runs pre-commit with the given arguments (defaults to install).
spellcheck *codespell-args # Spellchecks your markdown files.
lint-commit # Lints commit messages according to conventional commit rules.
```
To run the tests of this package, simply run:
```sh
# All tests
just t
# A single test
just t tests/test_dummy.py
# Pass arguments to pytest like this
just t -k test_dummy -vv
```
### Managing requirements
`poetry` is the tool we use for managing requirements in this project. The generated virtual environment is kept within the directory of the project (in a directory named `.venv`), thanks to the option `POETRY_VIRTUALENVS_IN_PROJECT=1`. Refer to the [poetry documentation](https://python-poetry.org/docs/cli/) to see the list of available commands.
As a short summary:
- Add a dependency:
poetry add foo-bar
- Remove a dependency:
poetry remove foo-bar
- Update a dependency (within constraints set in `pyproject.toml`):
poetry update foo-bar
- Update the lockfile with the contents of `pyproject.toml` (for instance, when getting a conflict after a rebase):
poetry lock
- Check if `pyproject.toml` is in sync with `poetry.lock`:
poetry lock --check
### Commit messages
In this project we enforce [conventional commits](https://www.conventionalcommits.org) guidelines for commit messages. The usage of [commitizen](https://commitizen-tools.github.io/commitizen/) is recommended, but not required. Story numbers (JIRA, etc.) must go in the scope section of the commit message. Example message:
```
feat(#<issue-number>): add new feature x
```
Merge requests must be approved before they can be merged to the `main` branch, and all the steps in the `ci` pipeline must pass.
This project includes an optional pre-commit configuration. Note that all necessary checks are always executed in the ci pipeline, but
configuring pre-commit to execute some of them can be beneficial to reduce late errors. To do so, simply execute the following just recipe:
```sh
just pre-commit
```
Feel free to create [GitHub Issues](https://github.com/elementsinteractive/lgtm-ai/issues) for any feature request, bug, or suggestion!
## Contributors ✨
Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):
<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
<tbody>
<tr>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/scastlara"><img src="https://avatars.githubusercontent.com/u/7606872?v=4?s=50" width="50px;" alt="Sergio Castillo"/><br /><sub><b>Sergio Castillo</b></sub></a><br /><a href="https://github.com/elementsinteractive/lgtm-ai/commits?author=scastlara" title="Code">💻</a> <a href="#design-scastlara" title="Design">🎨</a> <a href="#ideas-scastlara" title="Ideas, Planning, & Feedback">🤔</a> <a href="#maintenance-scastlara" title="Maintenance">🚧</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/jbozanowski"><img src="https://avatars.githubusercontent.com/u/114900?v=4?s=50" width="50px;" alt="Jakub Bożanowski"/><br /><sub><b>Jakub Bożanowski</b></sub></a><br /><a href="https://github.com/elementsinteractive/lgtm-ai/commits?author=jbozanowski" title="Code">💻</a> <a href="#ideas-jbozanowski" title="Ideas, Planning, & Feedback">🤔</a> <a href="#maintenance-jbozanowski" title="Maintenance">🚧</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sacha-c"><img src="https://avatars.githubusercontent.com/u/3247529?v=4?s=50" width="50px;" alt="Sacha Brouté"/><br /><sub><b>Sacha Brouté</b></sub></a><br /><a href="https://github.com/elementsinteractive/lgtm-ai/commits?author=sacha-c" title="Code">💻</a> <a href="#ideas-sacha-c" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/sdn4z"><img src="https://avatars.githubusercontent.com/u/13658011?v=4?s=50" width="50px;" alt="Daniel"/><br /><sub><b>Daniel</b></sub></a><br /><a href="#ideas-sdn4z" title="Ideas, Planning, & Feedback">🤔</a></td>
<td align="center" valign="top" width="14.28%"><a href="https://github.com/Rooni"><img src="https://avatars.githubusercontent.com/u/916242?v=4?s=50" width="50px;" alt="Rooni"/><br /><sub><b>Rooni</b></sub></a><br /><a href="https://github.com/elementsinteractive/lgtm-ai/commits?author=Rooni" title="Code">💻</a></td>
</tr>
</tbody>
</table>
<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->
<!-- ALL-CONTRIBUTORS-LIST:END -->
This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!
Raw data
{
"_id": null,
"home_page": null,
"name": "lgtm-ai",
"maintainer": null,
"docs_url": null,
"requires_python": "<4,>=3.12",
"maintainer_email": null,
"keywords": "AI, code-review, linting, static-analysis, machine-learning, developer-tools, automation",
"author": "Sergio Castillo Lara",
"author_email": "s.cast.lara@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/cc/3c/c3ba2ef2771a06d743fa49bef393b2f394f2305005c1f4f2a4e2999ae619/lgtm_ai-0.8.0.tar.gz",
"platform": null,
"description": "<p align=\"center\">\n <img alt=\"lgtm-logo\" width=\"150\" src=\"./assets/lgtm-large.png\">\n</p>\n\n# lgtm-ai\n\n\n\n[](https://github.com/astral-sh/ruff)\n[](https://pypi.org/project/lgtm-ai/)\n[](LICENSE)\n\n---\n\nlgtm-ai is your AI-powered code review companion. It generates code reviews using your favorite LLMs and helps human reviewers with detailed, context-aware reviewer guides. Supports GitHub, GitLab, and major AI models including GPT-4, Claude, Gemini, and more.\n\n**Table of Contents**\n- [Quick Usage](#quick-usage)\n - [Review](#review)\n - [Reviewer Guide](#reviewer-guide)\n- [Installation](#installation)\n- [How it works](#how-it-works)\n - [Review scores and comment categories](#review-scores-and-comment-categories)\n - [Supported Code Repository Services](#supported-code-repository-services)\n - [Supported AI models](#supported-ai-models)\n - [OpenAI](#openai)\n - [Google Gemini](#google-gemini)\n - [Anthropic's Claude](#anthropics-claude)\n - [Mistral AI](#mistral-ai)\n - [DeepSeek](#deepseek)\n - [Local models](#local-models)\n - [CI/CD Integration](#cicd-integration)\n - [Configuration](#configuration)\n - [Configuration file](#configuration-file)\n- [Contributing](#contributing)\n - [Running the project](#running-the-project)\n - [Managing requirements](#managing-requirements)\n - [Commit messages](#commit-messages)\n- [Contributors \u2728](#contributors-)\n\n\n## Quick Usage\n\n### Review\n\n```sh\n lgtm review --pr-url \"https://gitlab.com/your-repo/-/merge-requests/42\" \\\n --ai-api-key $OPENAI_API_KEY \\\n --git-api-key $GITLAB_TOKEN \\\n --model gpt-4.1 \\\n --publish\n```\n\nThis will generate a **review** like this one:\n\n<img src=\"./assets/review.png\" alt=\"lgtm-review\" height=\"250\"/>\n<br/>\n<img src=\"./assets/review-comment.png\" alt=\"lgtm-review-comment\" height=\"250\"/>\n\n\n### Reviewer Guide\n\n```sh\n lgtm guide --pr-url \"https://gitlab.com/your-repo/-/merge-requests/42\" \\\n --ai-api-key $OPENAI_API_KEY \\\n --git-api-key $GITLAB_TOKEN \\\n --model gpt-4.1 \\\n --publish\n```\n\nThis will generate a **reviewer guide** like this one:\n\n<img src=\"./assets/reviewer-guide.png\" alt=\"lgtm-review-guide\" height=\"250\"/>\n\n## Installation\n\n```sh\npip install lgtm-ai\n```\n\nOr you can use the official Docker image:\n\n```sh\ndocker pull elementsinteractive/lgtm-ai\n```\n\n## How it works\n\nlgtm reads the given pull request and feeds it to several AI agents to generate a code review or a reviewer guide. The philosophy of lgtm is to keep the models out of the picture and totally configurable, so that you can choose which model to use based on pricing, security, data privacy, or whatever is important to you.\n\nIf instructed (with the option `--publish`), lgtm will publish the review or guide to the pull request page as comments.\n\n### Review scores and comment categories\n\nReviews generated by lgtm will be assigned a **score**, using the following scale:\n\n| Score | Description |\n| ------ | --- |\n| LGTM \ud83d\udc4d | The PR is generally ready to be merged. |\n| Nitpicks \ud83e\udd13 | There are some minor issues, but the PR is almost ready to be merged. |\n| Needs Work \ud83d\udd27 | There are some issues with the PR, and it is not ready to be merged. The approach is generally good, the fundamental structure is there, but there are some issues that need to be fixed. |\n| Needs a Lot of Work \ud83d\udea8 | Issues are major, overarching, and/or numerous. However, the approach taken is not necessarily wrong. |\n| Abandon \u274c | The approach taken is wrong, and the author needs to start from scratch. The PR is not ready to be merged as is at all. |\n\nFor each review, lgtm may create several inline comments, pointing out specific issues within the PR. These comments belong to a **category** and have a **severity**. You can configure which categories you want lgtm to take a look at (see the [configuration section below](./README.md#configuration-file)). The available categories are:\n\n| Category | Description |\n| ------- | ----------- | \n| Correctness \ud83c\udfaf | Does the code behave as intended? Identifies logical errors, bugs, incorrect algorithms, broken functionality, or deviations from requirements. |\n| Quality \u2728 | Is the code clean, readable, and maintainable? Evaluates naming, structure, modularity, and adherence to clean code principles (e.g., SOLID, DRY, KISS). |\n| Testing \ud83e\uddea | Are there sufficient and appropriate tests? Includes checking for meaningful test coverage, especially for edge cases and critical paths. Are tests isolated, reliable, and aligned with the behavior being verified? |\n| Security \ud83d\udd12 | Does the code follow secure programming practices? Looks for common vulnerabilities such as injection attacks, insecure data handling, improper access control, hardcoded credentials, or lack of input validation. |\n\nThere are three available severities for comments:\n\n- LOW \ud83d\udd35\n- MEDIUM \ud83d\udfe1\n- HIGH \ud83d\udd34\n\n### Supported Code Repository Services\n\nlgtm aims to work with as many services as possible, and that includes remote repository providers. At the moment, lgtm supports:\n\n- [GitLab](https://gitlab.com) (only gitlab.com, not self-hosted)\n- [GitHub](https://github.com)\n\nlgtm will autodetect the url of the pull request passed to `--pr-url` automatically.\n\n### Supported AI models\n\nlgtm supports several AI models so you can hook up your preferred LLM to perform reviews for you.\n\nThis is the full list of supported models:\n\n#### OpenAI\n\nCheck out the OpenAI platform page to see [all available models provided by OpenAI](https://platform.openai.com/docs/overview).\n\nTo use OpenAI LLMs, you need to provide lgtm with an API Key, which can be generated in the [OpenAI platform page for your project, or your user](https://platform.openai.com/api-keys).\n\n\n<details>\n\n<summary>Supported OpenAI models</summary>\n\nThese are the main supported models, though the CLI may support additional ones due to the use of [pydantic-ai](https://ai.pydantic.dev).\n\n| Model name |\n| -------- |\n| gpt-5 |\n| gpt-5-mini |\n| gpt-4.1 |\n| gpt-4.1-mini |\n| gpt-4.1-nano |\n| gpt-4o * |\n| gpt-4o-mini |\n| o4-mini |\n| o3-mini |\n| o3 |\n| o1-preview |\n| o1-mini |\n| o1 |\n| gpt-4-turbo |\n| gpt-4 |\n| gpt-3.5-turbo |\n| chatgpt-4o-latest |\n\n</details>\n\n#### Google Gemini\n\nCheck out the [Gemini developer docs](https://ai.google.dev/gemini-api/docs/models) to see all models provided by Google.\n\nTo use Gemini LLMs, you need to provide lgtm an API Key, which can be generated [here](https://aistudio.google.com/apikey). \n\nThese are the main supported models, though the CLI may support additional ones due to the use of [pydantic-ai](https://ai.pydantic.dev). Gemini timestamps models, so be sure to always use the latest model of each family, if possible.\n\n\nFor Gemini models exclusively, you can provide a wildcard at the end of the model name and lgtm will attempt to select the latest model (e.g., `gemini-2.5-pro*`)\n\n\n<details>\n\n<summary>Supported Google's Gemini models</summary>\n\n\n| Model name |\n| ----------- |\n| gemini-2.5-pro |\n| gemini-2.5-pro-preview-06-05 |\n| gemini-2.5-pro-preview-05-06 |\n| gemini-2.5-flash |\n| gemini-2.0-pro-exp-02-05 |\n| gemini-2.0-flash |\n| gemini-1.5-pro |\n| gemini-1.5-flash |\n\n</details>\n\n#### Anthropic's Claude\n\nCheck out [Anthropic documentation](https://docs.anthropic.com/en/docs/about-claude/models/all-models) to see which models they provide. lgtm works with a subset of Claude models. To use Anthropic LLMs, you need to provide lgtm with an API Key, which can be generated from the [Anthropic Console](https://console.anthropic.com/dashboard).\n\n<details>\n\n<summary>Supported Anthropic models</summary>\n\nThese are the main supported models, though the CLI may support additional ones due to the use of [pydantic-ai](https://ai.pydantic.dev).\n\n| Model name |\n| ---------------------------- |\n| claude-sonnet-4-0 |\n| claude-3-7-sonnet-latest |\n| claude-3-5-sonnet-latest |\n| claude-3-5-haiku-latest |\n| claude-3-opus-latest |\n\n</details>\n\n#### Mistral AI\n\nCheck out the [Mistral documentation](https://docs.mistral.ai/getting-started/models/models_overview/) to see all models provided by Mistral.\n\nTo use Mistral LLMs, you need to provide lgtm with an API Key, which can be generated from Mistral's [Le Platforme](https://console.mistral.ai/api-keys).\n\n<details>\n\n<summary>Supported Mistral AI models</summary>\n\nThese are the main supported models, though the CLI may support additional ones due to the use of [pydantic-ai](https://ai.pydantic.dev).\n\n| Model name |\n| ------------------ |\n| mistral-large-latest |\n| mistral-small |\n| codestrallatest |\n\n</details>\n\n#### DeepSeek\n\nCheck out the [DeepSeek documentation](https://api-docs.deepseek.com/quick_start/pricing) to see all models provided by DeepSeek.\n\nAt the moment, lgtm only supports DeepSeek from `https://api.deepseek.com`: other providers and custom URLs are not supported. However, this is in our roadmap!\n\nTo get an API key for DeepSeek, create one at [DeepSeek Platform](https://platform.deepseek.com/usage).\n\n<details>\n\n<summary>Supported DeepSeek models</summary>\n\n| Model name |\n| ----------- |\n| deepseek-chat |\n| deepseek-reasoner |\n\n</details>\n\n#### Local models\n\nYou can run lgtm against a model available at a custom url (say, models running with [ollama](https://ollama.com) at http://localhost:11434/v1). These models need to be compatible with OpenAI. In that case, you need to pass the option `--model-url` (and you can choose to skip the option `--ai-api-token`). Check out the [pydantic-ai documentation](https://ai.pydantic.dev/models/openai/#openai-responses-api) to see more information about how lgtm interacts with these models.\n\n```sh\nlgtm review \\\n --pr-url https://github.com/group/repo/pull/1 \\\n --model llama3.2 \\\n --model-url http://localhost:11434/v1 \\\n ...\n```\n\n### CI/CD Integration\n\nlgtm is meant to be integrated into your CI/CD pipeline, so that PR authors can choose to request reviews by running the necessary pipeline step.\n\nFor GitLab, you can use this .gitlab-ci.yml step as inspiration:\n\n```yaml\nlgtm-review:\n image:\n name: docker.io/elementsinteractive/lgtm-ai\n entrypoint: [\"\"]\n stage: ai-review\n needs: []\n rules:\n - if: $CI_MERGE_REQUEST_ID\n when: manual\n script:\n - lgtm review --pr-url ${MR_URL} --git-api-key ${LGTM_GIT_API_KEY} --ai-api-key ${LGTM_AI_API_KEY} -v\n variables:\n MR_URL: \"${CI_PROJECT_URL}/-/merge_requests/${CI_MERGE_REQUEST_IID}\"\n```\n\nFor GitHub, we plan to provide a GitHub action soon. In the meantime, check out this repo's [lgtm workflow](./.github/workflows/lgtm.yml), with which you can trigger reviews in PRs by commenting `/lgtm review`.\n\n### Configuration\n\nYou can customize how lgtm works by passing cli arguments to it on invocation, or by using the *lgtm configuration file*. \n\n#### Configuration file\n\nlgtm uses a `.toml` file to configure how it works. It will autodetect a `lgtm.toml` file in the current directory, or you can pass a specific file path with the CLI option `--config <path>`. These are the available options at the moment:\n\n- **technologies**: You can specify, as a list of free strings, which technologies lgtm specializes in. This can be helpful for directing the reviewer towards specific technologies. By default, lgtm won't assume any technology and will just review the PR considering itself an \"expert\" in it.\n- **categories**: lgtm will, by default, evaluate several areas of the given PR (`Quality`, `Correctness`, `Testing`, and `Security`). You can choose any subset of these (e.g.: if you are only interested in `Correctness`, you can configure `categories` so that lgtm does not evaluate the other missing areas).\n- **model**: Choose which AI model you want lgtm to use.\n- **model_url**: When not using one of the specific supported models from the providers mentioned above, you can pass a custom url where the model is deployed.\n- **exclude**: Instruct lgtm to ignore certain files. This is important to reduce noise in reviews, but also to reduce the amount of tokens used for each review (and to avoid running into token limits). You can specify file patterns (`exclude = [\"*.md\", \"package-lock.json\"]`)\n- **output_format**: Format of the terminal output of lgtm. Can be `pretty` (default), `json`, and `markdown`.\n- **silent**: Do not print the review in the terminal.\n- **publish**: If `true`, it will post the review as comments on the PR page.\n- **ai_api_key**: API key to call the selected AI model. Can be given as a CLI argument, or as an environment variable (`LGTM_AI_API_KEY`).\n- **git_api_key**: API key to post the review in the source system of the PR. Can be given as a CLI argument, or as an environment variable (`LGTM_GIT_API_KEY`). This is required to not be empty if using a non-local model.\n- **ai_retries**: How many times to retry calls to the LLM when they do not succeed. By default, this is set to 1 (no retries at all).\n- **additional_context**: TOML array of extra context to send to the LLM. It supports setting the context directly in the `context` field, passing a relative file path so that lgtm downloads it from the repository, or passing any URL from which to download the context. Each element of the array must contain `prompt`, and either `context` (directly injecting context) or `file_url` (for directing lgtm to download it from there).\n\n**Example `lgtm.toml`:**\n\n```toml\ntechnologies = [\"Django\", \"Python\"]\ncategories = [\"Correctness\", \"Quality\", \"Testing\", \"Security\"]\nexclude = [\"*.md\"]\nmodel = \"gpt-4.1\"\nsilent = false\npublish = true\nai_retries = 1\n\n[[additional_context]]\nprompt = \"These are the development guidelines for the team, ensure the PR follows them\"\nfile_url = \"https://my.domain.com/dev-guidelines.md\"\n\n[[additional_context]]\nprompt = \"CI pipeline for the repo. Do not report issues that this pipeline would otherwise catch\"\nfile_url = \".github/workflows/pr.yml\"\n\n[[additional_context]]\nprompt = \"Consider these points when making your review\"\ncontext = '''\n- We avoid using libraries and rely mostly on the stdlib.\n- We follow the newest syntax available for Python (3.13).\n'''\n```\n\nAlternatively, lgtm also supports [pyproject.toml](https://packaging.python.org/en/latest/guides/writing-pyproject-toml/) files, you just need to nest the options inside `[tool.lgtm]`.\n\nWhen it comes to preference for selecting options, lgtm follows this preference order:\n\n `CLI options` > `lgtm.toml` > `pyproject.toml`\n\n\n## Contributing\n\n### Running the project\n\nThis project uses [`just`](https://github.com/casey/just) recipes to do all the basic operations (testing the package, formatting the code, etc.).\n\nInstallation: \n\n```sh\nbrew install just\n# or\nsnap install --edge --classic just\n```\n\nIt requires [poetry](https://python-poetry.org/docs/#installation).\n\nThese are the available commands for the justfile:\n\n```\nAvailable recipes:\n help # Shows list of recipes.\n venv # Generate the virtual environment.\n clean # Cleans all artifacts generated while running this project, including the virtualenv.\n test *test-args='' # Runs the tests with the specified arguments (any path or pytest argument).\n t *test-args='' # alias for `test`\n test-all # Runs all tests including coverage report.\n format # Format all code in the project.\n lint # Lint all code in the project.\n pre-commit *precommit-args # Runs pre-commit with the given arguments (defaults to install).\n spellcheck *codespell-args # Spellchecks your markdown files.\n lint-commit # Lints commit messages according to conventional commit rules.\n```\n\nTo run the tests of this package, simply run:\n\n```sh\n# All tests\njust t\n\n# A single test\njust t tests/test_dummy.py\n\n# Pass arguments to pytest like this\njust t -k test_dummy -vv\n```\n\n### Managing requirements\n\n`poetry` is the tool we use for managing requirements in this project. The generated virtual environment is kept within the directory of the project (in a directory named `.venv`), thanks to the option `POETRY_VIRTUALENVS_IN_PROJECT=1`. Refer to the [poetry documentation](https://python-poetry.org/docs/cli/) to see the list of available commands.\n\nAs a short summary:\n\n- Add a dependency:\n\n poetry add foo-bar\n\n- Remove a dependency:\n\n poetry remove foo-bar\n\n- Update a dependency (within constraints set in `pyproject.toml`):\n\n poetry update foo-bar\n\n- Update the lockfile with the contents of `pyproject.toml` (for instance, when getting a conflict after a rebase):\n\n poetry lock\n\n- Check if `pyproject.toml` is in sync with `poetry.lock`:\n\n poetry lock --check\n\n### Commit messages\n\nIn this project we enforce [conventional commits](https://www.conventionalcommits.org) guidelines for commit messages. The usage of [commitizen](https://commitizen-tools.github.io/commitizen/) is recommended, but not required. Story numbers (JIRA, etc.) must go in the scope section of the commit message. Example message:\n\n```\nfeat(#<issue-number>): add new feature x\n```\n\nMerge requests must be approved before they can be merged to the `main` branch, and all the steps in the `ci` pipeline must pass.\n\nThis project includes an optional pre-commit configuration. Note that all necessary checks are always executed in the ci pipeline, but\nconfiguring pre-commit to execute some of them can be beneficial to reduce late errors. To do so, simply execute the following just recipe:\n\n```sh\njust pre-commit\n```\n\nFeel free to create [GitHub Issues](https://github.com/elementsinteractive/lgtm-ai/issues) for any feature request, bug, or suggestion!\n\n## Contributors \u2728\n\nThanks goes to these wonderful people ([emoji key](https://allcontributors.org/docs/en/emoji-key)):\n\n<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->\n<!-- prettier-ignore-start -->\n<!-- markdownlint-disable -->\n<table>\n <tbody>\n <tr>\n <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/scastlara\"><img src=\"https://avatars.githubusercontent.com/u/7606872?v=4?s=50\" width=\"50px;\" alt=\"Sergio Castillo\"/><br /><sub><b>Sergio Castillo</b></sub></a><br /><a href=\"https://github.com/elementsinteractive/lgtm-ai/commits?author=scastlara\" title=\"Code\">\ud83d\udcbb</a> <a href=\"#design-scastlara\" title=\"Design\">\ud83c\udfa8</a> <a href=\"#ideas-scastlara\" title=\"Ideas, Planning, & Feedback\">\ud83e\udd14</a> <a href=\"#maintenance-scastlara\" title=\"Maintenance\">\ud83d\udea7</a></td>\n <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/jbozanowski\"><img src=\"https://avatars.githubusercontent.com/u/114900?v=4?s=50\" width=\"50px;\" alt=\"Jakub Bo\u017canowski\"/><br /><sub><b>Jakub Bo\u017canowski</b></sub></a><br /><a href=\"https://github.com/elementsinteractive/lgtm-ai/commits?author=jbozanowski\" title=\"Code\">\ud83d\udcbb</a> <a href=\"#ideas-jbozanowski\" title=\"Ideas, Planning, & Feedback\">\ud83e\udd14</a> <a href=\"#maintenance-jbozanowski\" title=\"Maintenance\">\ud83d\udea7</a></td>\n <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/sacha-c\"><img src=\"https://avatars.githubusercontent.com/u/3247529?v=4?s=50\" width=\"50px;\" alt=\"Sacha Brout\u00e9\"/><br /><sub><b>Sacha Brout\u00e9</b></sub></a><br /><a href=\"https://github.com/elementsinteractive/lgtm-ai/commits?author=sacha-c\" title=\"Code\">\ud83d\udcbb</a> <a href=\"#ideas-sacha-c\" title=\"Ideas, Planning, & Feedback\">\ud83e\udd14</a></td>\n <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/sdn4z\"><img src=\"https://avatars.githubusercontent.com/u/13658011?v=4?s=50\" width=\"50px;\" alt=\"Daniel\"/><br /><sub><b>Daniel</b></sub></a><br /><a href=\"#ideas-sdn4z\" title=\"Ideas, Planning, & Feedback\">\ud83e\udd14</a></td>\n <td align=\"center\" valign=\"top\" width=\"14.28%\"><a href=\"https://github.com/Rooni\"><img src=\"https://avatars.githubusercontent.com/u/916242?v=4?s=50\" width=\"50px;\" alt=\"Rooni\"/><br /><sub><b>Rooni</b></sub></a><br /><a href=\"https://github.com/elementsinteractive/lgtm-ai/commits?author=Rooni\" title=\"Code\">\ud83d\udcbb</a></td>\n </tr>\n </tbody>\n</table>\n\n<!-- markdownlint-restore -->\n<!-- prettier-ignore-end -->\n\n<!-- ALL-CONTRIBUTORS-LIST:END -->\n\nThis project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome!\n",
"bugtrack_url": null,
"license": null,
"summary": "Your AI-powered code review companion",
"version": "0.8.0",
"project_urls": null,
"split_keywords": [
"ai",
" code-review",
" linting",
" static-analysis",
" machine-learning",
" developer-tools",
" automation"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "a96c2df75dd544a71f5a7769aad147246cde2bfc60e6a3979dfd3bb9dc8ebdb3",
"md5": "aed0c7a74bb9eb69de891948b4c8947d",
"sha256": "365c0b813d0b647ab9ecfaa9223c4addb33360fdb18b5688ebe58593bcf68c55"
},
"downloads": -1,
"filename": "lgtm_ai-0.8.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "aed0c7a74bb9eb69de891948b4c8947d",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": "<4,>=3.12",
"size": 51633,
"upload_time": "2025-08-12T09:52:24",
"upload_time_iso_8601": "2025-08-12T09:52:24.918549Z",
"url": "https://files.pythonhosted.org/packages/a9/6c/2df75dd544a71f5a7769aad147246cde2bfc60e6a3979dfd3bb9dc8ebdb3/lgtm_ai-0.8.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "cc3cc3ba2ef2771a06d743fa49bef393b2f394f2305005c1f4f2a4e2999ae619",
"md5": "fba99216b2e0cc04aeafaa3a4da0b278",
"sha256": "4a9513ad3bd421484ec57760d8b5a351d2de36f1a36850d67524744265d66162"
},
"downloads": -1,
"filename": "lgtm_ai-0.8.0.tar.gz",
"has_sig": false,
"md5_digest": "fba99216b2e0cc04aeafaa3a4da0b278",
"packagetype": "sdist",
"python_version": "source",
"requires_python": "<4,>=3.12",
"size": 47146,
"upload_time": "2025-08-12T09:52:25",
"upload_time_iso_8601": "2025-08-12T09:52:25.999090Z",
"url": "https://files.pythonhosted.org/packages/cc/3c/c3ba2ef2771a06d743fa49bef393b2f394f2305005c1f4f2a4e2999ae619/lgtm_ai-0.8.0.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-08-12 09:52:25",
"github": false,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"lcname": "lgtm-ai"
}