Helix Core is now P4 and Helix Swarm is now P4 Code Review. Product user interfaces will be updated soon. Learn more >>

Documentation | 2025.5

# AI for code analysis

P4 Code Review enhances the code review process by using an AI model (similar to those from OpenAI) to generate explanations for code diffs in a file, making it easier for developers to understand and review changes.

You can send the whole diff of a file for AI code analysis or just a selection.

To send the whole diff for AI code analysis, click the AI button in the numbered panel.

To send a selection of code, first select the code to send for AI code analysis, then click the AI button .

A loading tooltip will appear while the AI summary is being generated.

The AI code analysis is returned as text in a pop window.

Only the diff (or selected diff content), filename, and the file extension are sent to the AI vendor for analysis. P4 Code Review does not send the whole file.

An AI Assistant is also available for comments on a review page. For information on how to configure the AI Assistant for comments, see AI Assistant for comments.

P4 Code Review has been tested with the following AI vendors and models:

- OpenAI - `gpt-4`

- LM Studio - all provided models which include:

  - `lmstudio-community/gemma-3-1B-it-qat-GGUF`
  - `lmstudio-community/Qwen3-1.7B-GGUF`
  - `lmstudio-community/DeepSeek-R1-Distill-Llama-8B-GGUF`
  - `lmstudio-community/Meta-Llama-3.1-8B-Instruct-GGU`

The configuration to integrate AI into P4 Code Review is specified within an ai_review block in the `SWARM_ROOT/data/config.php` file. By default, ai_review block is disabled. To enable AI-driven code explanations for a diff, set enabled to true.

To review the terms for using your own API keys, download the API Key Usage Agreement for Perforce P4 Code Review.

Your search for returned results