> For the complete documentation index, see [llms.txt](https://docs.sonarsource.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.sonarsource.com/sonarqube-server/project-administration/ai-features/set-up-ai-code-assurance.md).

# Set up AI Code Assurance

In SonarQube Server 2026.5, manage your AI Code Assurance standards using the SonarQube API.

Setting up AI Code Assurance is a three-step process laid out in full on the [Set your AI standards](/sonarqube-server/quality-standards-administration/ai-code-assurance/overview.md) page.

## Assuring your AI code <a href="#assuring-your-ai-code" id="assuring-your-ai-code"></a>

Sonar recognizes that 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. [Set your AI standards](/sonarqube-server/quality-standards-administration/ai-code-assurance/overview.md#label-projects-with-ai-code)
2. [Set your AI standards](/sonarqube-server/quality-standards-administration/ai-code-assurance/overview.md#apply-qualified-quality-gate)
3. Publish an AI Code Assurance badge externally to your websites to [Monitor projects with AI code](/sonarqube-server/quality-standards-administration/ai-code-assurance/monitor-projects-with-ai-code.md).

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

## Using the API to set up AI Code Assurance <a href="#use-the-api-to-set-up-ai-code-assurance" id="use-the-api-to-set-up-ai-code-assurance"></a>

To mark a project with ![$contains-ai-code](https://content.gitbook.com/content/mX1WoFEHhJp6VdSbyTDi/blobs/8UTrqVTNVUUmpRRWoiqD/c151514ef7beca0f865ee429bc9fe0e33b05ceb4.svg):

```bash
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:

```bash
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>
```

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

* [Overview](/sonarqube-server/project-administration/ai-features/overview.md) of AI features at project level
* [Overview](/sonarqube-server/instance-administration/ai-features/overview.md) of AI features for instance administration
* [AI CodeFix](/sonarqube-server/project-administration/ai-features/enable-ai-codefix.md) to get AI-generated fix suggestions
* [Agent Centric Development Cycle](https://docs.sonarsource.com/agent-centric-development-cycle/) of AI capabilities


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

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

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.sonarsource.com/sonarqube-server/project-administration/ai-features/set-up-ai-code-assurance.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
