> For the complete documentation index, see [llms.txt](https://dnotifier.gitbook.io/product-docs/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://dnotifier.gitbook.io/product-docs/ai/multi-models/open-ai-integration.md).

# OpenAI integration

`provider` value: `open_ai`

OpenAI is usually the first connection people set up. You can paste your own OpenAI API key in the portal, or use DNotifier-billed OpenAI if your plan includes that.

Model ids look like `gpt-4o`, `gpt-4o-mini`, `o3-mini` — whatever that portal connection lists.

## In the portal

1. Open [app.dnotifier.com](https://app.dnotifier.com).
2. **Projects** (pick the project) → **AI Studio** → **Providers** → **OpenAI**.
3. Either paste an API key (plus org/project if the form asks) **or** enable the DNotifier subscription path.
4. Save. Glance at the model list so you know what you can pass as `model`.

Leave the key in the portal. Your app only needs `appId` / `secret`.

## From the SDK

HTTP transport, connected, AI enabled — then:

{% tabs %}
{% tab title="JavaScript" %}

```js
await notifier.sendAI({
  senderId: USER_ID,
  provider: "open_ai",
  model: "gpt-4o",
  message: {
    useKnowledgeBase: false,
    messages: [
      { role: "system", content: "Keep answers short." },
      { role: "user", content: "Three reasons to use HTTP for AI calls?" },
    ],
  },
  saveHistory: true,
});
```

{% endtab %}

{% tab title="Python" %}

```python
await notifier.send_ai(
    sender_id=user_id,
    provider="open_ai",
    model="gpt-4o",
    message={
        "useKnowledgeBase": False,
        "messages": [
            {"role": "system", "content": "Keep answers short."},
            {"role": "user", "content": "Three reasons to use HTTP for AI calls?"},
        ],
    },
    save_history=True,
)
```

{% endtab %}

{% tab title="Dart" %}

```dart
await notifier.sendAI(
  senderId: userId,
  provider: 'open_ai',
  model: 'gpt-4o',
  message: {
    'useKnowledgeBase': false,
    'messages': [
      {'role': 'system', 'content': 'Keep answers short.'},
      {'role': 'user', 'content': 'Three reasons to use HTTP for AI calls?'},
    ],
  },
  saveHistory: true,
);
```

{% endtab %}
{% endtabs %}

Support-style agent that always hits mini unless you override:

```js
const supportAgent = DNotifier.defineAgent({
  name: "support",
  provider: "open_ai",
  model: "gpt-4o-mini",
  async run(ctx) {
    return ctx.sendAI({
      message: { text: ctx.input.question },
      saveHistory: false,
    });
  },
});
```

RAG is the same call with `useKnowledgeBase: true`:

```js
await notifier.sendAI({
  senderId: USER_ID,
  provider: "open_ai",
  model: "gpt-4o",
  message: {
    useKnowledgeBase: true,
    messages: [{ role: "user", content: "What's our refund window?" }],
  },
});
```

If something blows up, it's almost always: wrong key in the portal, model not enabled on that connection, or AI off on the plan. See [First OpenAI call](https://dnotifier.gitbook.io/product-docs/tutorials/tutorials/first-openai-call.md) for a full walkthrough.

[Back to multi-model overview](https://dnotifier.gitbook.io/product-docs/ai/multi-models.md) · [Anthropic](https://dnotifier.gitbook.io/product-docs/ai/multi-models/anthropic-integration.md)
