# Enabling AI CodeFix

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 feature is available in SonarQube Server, Enterprise and Data Center editions.

Using AI CodeFix 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\_20253\_Supported\_LLM\_version</code> your own [Azure OpenAI LLM Service model](https://learn.microsoft.com/en-us/azure/ai-services/openai/concepts/models?tabs=global-standard%2Cstandard-chat-completions), 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[#ai-codefix-rules](https://docs.sonarsource.com/sonarqube-server/2025.3/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** > **AI CodeFix** and select **Enable AI CodeFix**.
2. Select your **Provider**:
   * The default option is Sonar’s **OpenAI** which uses <code class="expression">space.vars.SQS\_20253\_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.azure.com/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/).
     4. Optional for enhanced security: Navigate to **Configuration** > **General Settings** > **Security** and select **Enforce Azure OpenAI EndPoint Domain** to only accept service endpoint URL domains that terminate with `.openai.azure.com`. Please double-check your entry at Step 2.2.
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\_20253\_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 the [fixing](https://docs.sonarsource.com/sonarqube-server/2025.3/user-guide/issues/fixing "mention") page 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 the system property `sonar.ai.codefix.hidden` to `true`. For more information, see the[configuration-methods](https://docs.sonarsource.com/sonarqube-server/2025.3/server-installation/system-properties/configuration-methods "mention") page.

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

Once AI CodeFix is enabled, users will be able to select **Generate AI Fix** on eligible issues and copy/paste the fix into their IDE with the **Open in IDE** feature when using connected mode.

The easiest way to use AI CodeFix is by using AI CodeFix in your IDE. Simply open your project in SonarQube for [VS Code](https://app.gitbook.com/o/2ibCvzwZt86Nlk2zloB7/s/6LPRABg3ubAJhpfR5K0Y/ "mention") or SonarQube for [IntelliJ](https://app.gitbook.com/o/2ibCvzwZt86Nlk2zloB7/s/NvI4wotPmITyM0mnsmtp/ "mention"), and set up connected mode with SonarQube Server. In your IDE, select an issue marked with the ![4be9087a2b059c269f15df202838af7a74e71a96.svg](https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4vN6mMcoPndARxvycboz%2Fuploads%2Fgit-blob-975a17de7ce8ae3b164dd9f9db9c791adb294bbb%2F4be9087a2b059c269f15df202838af7a74e71a96.svg?alt=media) icon, open the **Rule description** > ![4be9087a2b059c269f15df202838af7a74e71a96.svg](https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4vN6mMcoPndARxvycboz%2Fuploads%2Fgit-blob-975a17de7ce8ae3b164dd9f9db9c791adb294bbb%2F4be9087a2b059c269f15df202838af7a74e71a96.svg?alt=media)**AI CodeFix** tab, and select ![4be9087a2b059c269f15df202838af7a74e71a96.svg](https://files.gitbook.com/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F4vN6mMcoPndARxvycboz%2Fuploads%2Fgit-blob-975a17de7ce8ae3b164dd9f9db9c791adb294bbb%2F4be9087a2b059c269f15df202838af7a74e71a96.svg?alt=media)**Generate Fix**. A fix will be generated in the code editor and you’ll have a chance to **Apply** or **Decline** the suggestion.

* For IntelliJ, see [AI CodeFix #AI CodeFix in your IDE](https://app.gitbook.com/s/NvI4wotPmITyM0mnsmtp/ai-capabilities/ai-codefix#ai-codefix "mention").
* For VS Code, see [AI CodeFix #AI CodeFix in your IDE](https://app.gitbook.com/s/6LPRABg3ubAJhpfR5K0Y/ai-capabilities/ai-codefix#ai-codefix "mention").

For complete details about using AI CodeFix to fix your issues in SonarQube Cloud, see [#getting-ai-generated-fix-suggestions](https://docs.sonarsource.com/sonarqube-server/2025.3/user-guide/issues/fixing#getting-ai-generated-fix-suggestions "mention").

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

## Marking a project as containing AI-generated code <a href="#marking-a-project-as-containing-ai-generated-code" id="marking-a-project-as-containing-ai-generated-code"></a>

Sonar recognizes that AI-generated code should be monitored with additional quality standards and offers administrators a series of project labels and custom quality gate certifications described on the [overview](https://docs.sonarsource.com/sonarqube-server/2025.3/quality-standards-administration/ai-code-assurance/overview "mention") page.

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

* [#ai-codefix-rules](https://docs.sonarsource.com/sonarqube-server/2025.3/user-guide/rules/rules-for-ai-codefix#ai-codefix-rules "mention")
* [overview](https://docs.sonarsource.com/sonarqube-server/2025.3/ai-capabilities/overview "mention") of AI capabilities in SonarQube Server
* [connected-mode](https://docs.sonarsource.com/sonarqube-server/2025.3/user-guide/connected-mode "mention")


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sonarsource.com/sonarqube-server/2025.3/instance-administration/ai-features/enable-ai-codefix.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
