Start Free
Latest | Project administration | AI features | Set up AI Code Assurance

Setting up AI Code Assurance

On this page

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

Assuring your AI code

SonarQube Server 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. Label your project as containing AI code
  2. Apply a quality gate for AI Code Assurance
  3. Publish an AI Code Assurance badge externally to your websites to Monitor projects containing AI code.

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>



Was this page helpful?

© 2008-2025 SonarSource SA. All rights reserved. SONAR, SONARSOURCE, SONARQUBE, and CLEAN AS YOU CODE are trademarks of SonarSource SA.

Creative Commons License