# AI-generated fix suggestions

Sonar’s AI CodeFix uses a large language model (LLM) to automatically generate AI-driven code fixes for the issues discovered by SonarQube Server. The process is simple. When you request a fix, the affected code and issue description are sent to an LLM. AI CodeFix then proposes an edit that resolves the problem without changing the code’s functionality.

AI CodeFix currently uses <code class="expression">space.vars.SQS\_20252\_Supported\_LLM\_version</code> your own Azure OpenAI LLM, to suggest fixes for a select set of rules in Java, JavaScript, TypeScript, Python, HTML, CSS, C#, and C++. To learn more about which rules are eligible for AI CodeFix, please see the list of [#ai-codefix-rules](https://docs.sonarsource.com/sonarqube-server/2025.2/user-guide/rules/rules-for-ai-codefix#ai-codefix-rules "mention").

## Sharing your code with Sonar <a href="#sharing-your-code-with-sonar" id="sharing-your-code-with-sonar"></a>

When you select a self-hosted LLM, your code stays within your network. However, Sonar’s AI CodeFix service needs to send the latest prompts and supported rule descriptions therefore, your instance of SonarQube server will still need internet connectivity.

If you use Sonar’s AI CodeFix LLM, the affected code snippet will be sent by the AI CodeFix service to the selected LLM. Service agreements with Sonar’s LLMs prevent your code from being used to train those models.

For details about terms and conditions, please refer to the [AI CodeFix terms](https://www.sonarsource.com/legal/ai-codefix-terms/) in our [Legal Documentation](https://www.sonarsource.com/legal/).

## Enabling AI-generated fix suggestions <a href="#enabling-ai-generated-fix-suggestions" id="enabling-ai-generated-fix-suggestions"></a>

As an Instance Admin, you can enable or disable AI-generated fix suggestions on your projects. To enable AI CodeFix:

1. Go to **Administration** > **Configuration** > **General Settings** > **Early Access** > **Enable AI-Generated fix suggestions** and select **Enable AI CodeFix**.
2. Select your **Provider**:
   * The default option is Sonar’s **OpenAI** which uses <code class="expression">space.vars.SQS\_20252\_Recommended\_LLM\_version</code>.
   * To choose your own **Azure OpenAI** LLM:
     1. Select **Self-hosted Bring Your Own Model**.
     2. Provide your Azure OpenAI **Endpoint**. The endpoint URL should include the `deployment-id` and `api-version` parameters.\
        Here is an example: `https://<YOUR-ENDPOINT>/openai/deployments/<YOUR-DEPLOYMENT-ID>/completions?api-version=<YOUR-API-VERSION>`
     3. Provide your Azure OpenAI **API Key**. For information about using Azure AI models, see the [Azure OpenAI Service documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/).
3. Once AI CodeFix is enabled, choose either **All projects** or **Only selected projects:**

When choosing **Only selected projects**, add projects individually from the list to activate the feature. New projects will not be added automatically.

{% hint style="warning" %}
Sonar recommends using <code class="expression">space.vars.SQS\_20252\_Recommended\_LLM\_version</code> as your Azure OpenAI Service model because it produces the best results. Using other models may produce unexpected fix suggestions that have undesirable effects.

For more information on your choices, see the [Azure documentation on service models](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models?tabs=global-standard%2Cstandard-chat-completions).
{% endhint %}

{% hint style="info" %}
You’ll need a connection to the internet to access SonarQube Server’s AI CodeFix service.

The service is provided via api.sonarqube.io and has these static IP addresses:

* 99.83.135.55 (CIDR: 99.83.135.55/32)
* 15.197.164.24 (CIDR: 15.197.164.24/32)
  {% endhint %}

Once enabled, developers can get AI-generated fix suggestions from the **Issues** page in their projects. See [fixing](https://docs.sonarsource.com/sonarqube-server/2025.2/user-guide/issues/fixing "mention") for more details.

### Disabling AI CodeFix <a href="#disabling-ai-codefix" id="disabling-ai-codefix"></a>

To disable AI CodeFix completely in SonarQube Server and hide the feature from all users, including Instance Admins, set `sonar.ai.codefix.hidden=true` in your sonar.properties file.

## Getting AI-generated fix suggestions <a href="#getting-ai-generated-fix-suggestions" id="getting-ai-generated-fix-suggestions"></a>

AI-generated fix suggestions are available for a select set of rules in Java, JavaScript, TypeScript, Python, HTML, CSS, C#, and C++. To learn more about which rules are eligible for AI CodeFix, please see the list of [#ai-codefix-rules](https://docs.sonarsource.com/sonarqube-server/2025.2/user-guide/rules/rules-for-ai-codefix#ai-codefix-rules "mention").

When an Instance Admin [#enabling-ai-generated-fix-suggestions](#enabling-ai-generated-fix-suggestions "mention"), you can get an AI-generated fix suggestion for eligible issues. The suggestions are generated using the LLM defined by the Instance Admin.

To generate a fix suggestion:

* [retrieving](https://docs.sonarsource.com/sonarqube-server/2025.2/user-guide/issues/retrieving "mention") and open its detail view. If an AI CodeFix is an option for that particular issue, you will see the **Generate AI Fix** button.
* From either the **Where is the Issue?** or the **AI CodeFix** tabs, select **Generate Fix**.

![](https://3577027091-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F69lEOGGgOhCpumODGD9v%2Fuploads%2Fgit-blob-98a3ac6f6755ed278f02b1908d9995d05489bd78%2F19c752ff864d7cb5388871e3118c68ead3785d6a.png?alt=media)

An AI CodeFix will be generated, and you’ll see a diff view in the **AI CodeFix** tab. If you’re using SonarQube for IDE and have [connected-mode](https://docs.sonarsource.com/sonarqube-server/2025.2/user-guide/connected-mode "mention") set up, select **View fix in IDE** to streamline the process and see the diff view in your IDE. Then, simply copy and paste the generated fix into your IDE.

* If you are running SonarQube for Visual Studio, selecting **View fix in IDE** will directly paste the fix suggestion into your IDE.

An AI Code Assurance badge is available to mark your AI projects as reviewed by SonarQube Server. Any user with project access can use the badge. For more detailed instructions, see the [#label-projects-with-ai-code](https://docs.sonarsource.com/sonarqube-server/2025.2/ai-standards#label-projects-with-ai-code "mention") article on the *Project settings* page.

## Usage limits <a href="#limits" id="limits"></a>

Limits are placed on the AI CodeFix feature to manage abuse. Developers will be notified directly when the monthly allocation is reached for your organization. If the instance is blocked due to reaching the allowance, users attempting to generate a fix will see an error message. Usage quotas are reset on the first day of each month.

SonarQube Server instances that are using a self-hosted LLM are not subject to Sonar’s limits however, you may encounter rate limits from your self-hosted LLM provider.

## AI Code Assurance <a href="#ai-code-assurance" id="ai-code-assurance"></a>

Sonar recognizes that AI-generated code should be monitored with additional quality standards and offers administrators a series of tools described on the [ai-standards](https://docs.sonarsource.com/sonarqube-server/2025.2/ai-capabilities/ai-standards "mention") page.

It’s possible to view ratings for projects with AI Code Assurance in your portfolios beginning in the [Enterprise edition](https://www.sonarsource.com/plans-and-pricing/enterprise/). There, you will see a breakdown of projects, applications, and nested portfolios that include the standards you’ve set for AI-generated code. See the [#portfolio-breakdown](https://docs.sonarsource.com/sonarqube-server/2025.2/user-guide/viewing-reports/portfolios#portfolio-breakdown "mention") article for more information.

## Related pages <a href="#related-pages" id="related-pages"></a>

* [overview](https://docs.sonarsource.com/sonarqube-server/2025.2/ai-capabilities/overview "mention")
* [#ai-codefix-rules](https://docs.sonarsource.com/sonarqube-server/2025.2/user-guide/rules/rules-for-ai-codefix#ai-codefix-rules "mention")
* [autodetect-ai-code](https://docs.sonarsource.com/sonarqube-server/2025.2/ai-capabilities/autodetect-ai-code "mention")
* see [#getting-ai-generated-fix-suggestions](https://docs.sonarsource.com/sonarqube-server/2025.2/user-guide/issues/fixing#getting-ai-generated-fix-suggestions "mention")
* see [#label-projects-with-ai-code](https://docs.sonarsource.com/sonarqube-server/2025.2/ai-standards#label-projects-with-ai-code "mention")
