For the complete documentation index, see llms.txt. This page is also available as Markdown.

Set up AI Code Assurance

Manage your AI Code Assurance standards in SonarQube Server 2025.1 using the SonarQube API.

For AI agents: You're in the SonarQube Server 2025.1 documentation. SonarQube Server 2025.1 is no longer patched. To get patches, upgrade to the latest version. For a list of all 2025.1 pages, see the SonarQube Server 2025.1 page index. For the whole site, see the page index or the full text. For another version, replace 2025.1 in the URL with that version. The latest version has no version number in its URL.

Setting up AI Code Assurance is a three-step process laid out in full on the Set your AI standards page.

Assuring your AI code

Sonar recognizes that AI-generated code should be monitored with additional quality standards. Recommended checks include high standards to reduce code complexity, remove bugs, and eliminate injection vulnerabilities. SonarQube’s AI Code Assurance features bring confidence that your AI-generated code is being reviewed to avoid any accountability crisis.

These objectives are achieved with three features that allow Quality Standard administrators to qualify projects as AI Code Assured:

  1. Publish an Using the AI Code Assurance badge externally to your websites (optional)

Steps 1 and 2 can be accomplished using the SonarQube Server API.

Using the API to set up AI Code Assurance

To mark a project with $contains-ai-code:

curl -XPOST -H 'Authorization: Bearer <YOUR_SONARQUBE_SERVER_TOKEN>'<YOUR_SONARQUBE_URL>/api/projects/set_contains_ai_code?contains_ai_code=true&project=<YOUR_PROJECT_KEY>

To assign an AI Code Assured quality gate to a project:

curl -XPOST -H 'Authorization: Bearer <YOUR_SONARQUBE_SERVER_TOKEN>'<YOUR_SONARQUBE_URL>/api/qualitygates/select?gateName=<NAME_OF_YOUR_AI_ASSURED_QUALITY_GATE>&projectKey=<YOUR_PROJECT_KEY>

Last updated

Was this helpful?