> 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/instance-administration/ai-features/llm-providers/openai.md).

# OpenAI

Register OpenAI as an LLM provider on SonarQube Server 2026.5, using your own OpenAI API key.

Use the **OpenAI** provider type to reach OpenAI's own API directly, authenticated with your OpenAI API key.

To select this provider and choose a model for an AI agent, see [LLM providers](/sonarqube-server/instance-administration/ai-features/llm-providers.md#selecting-for-a-capability); for the steps that apply to every provider type, see [LLM providers](/sonarqube-server/instance-administration/ai-features/llm-providers.md).

## Prerequisites <a href="#prerequisites" id="prerequisites"></a>

* An OpenAI API key with access to the models you want to use.

## Fields <a href="#fields" id="fields"></a>

| Field       | Required | What to enter        |
| ----------- | -------- | -------------------- |
| **API key** | Yes      | Your OpenAI API key. |

SonarQube Server already knows OpenAI's endpoint (`https://api.openai.com/v1`), so there's no endpoint field to fill in.

To reach OpenAI through a gateway or proxy instead of its own API, register a **Custom** provider instead; see [Custom](/sonarqube-server/instance-administration/ai-features/llm-providers/custom.md).

## What happens when you save <a href="#saving" id="saving"></a>

SonarQube Server tests the connection when you save, the same as for Custom and Azure AI Foundry. If the test fails, SonarQube Server does not add the provider, and the form reports the problem.

## Entering the model identifier <a href="#model-identifier" id="model-identifier"></a>

1. Find the model in OpenAI's model catalog.
2. Copy the identifier exactly as OpenAI names it, for example `gpt-5.5`.
3. Go to the agent's page under **Administration** > **Configuration** > **AI capabilities**, paste the identifier into the model field, and select **Save**.

If adding the provider fails, see [LLM providers](/sonarqube-server/instance-administration/ai-features/llm-providers.md#troubleshooting).


---

# 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/instance-administration/ai-features/llm-providers/openai.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.
