> For the complete documentation index, see [llms.txt](https://docs.dapta.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.dapta.ai/flow-studio/nodes/openai-node.md).

# OpenAI Node

Add the OpenAI node to a flow, run it on Dapta AI or your own OpenAI key, pick a GPT model, attach files and choose how the answer comes back.

The **OpenAI node** lets a flow call an OpenAI GPT model — summarize a text, classify a message, extract fields from free text, read a PDF or an image, or draft a reply — and use the answer in the steps that follow.

{% hint style="info" %}
**Using an older AI node?** Flows built before these nodes may still use the previous Gemini, Claude or OpenAI AI nodes, which now show **This node is deprecated**. The older Gemini and Claude nodes are billed in Dapta credits from September 15, 2026, and the older OpenAI node is no longer maintained. Replace them with this node.
{% endhint %}

***

**📘 What you'll learn in this document:**

* **Step 1:** Add the node
* **Step 2:** Choose the **Connection** — who pays for the model
* **Step 3:** Pick a **Model**
* **Step 4:** Write your **Prompt**
* **Step 5:** Add **Attachments** (optional)
* **Step 6:** Fine-tune the **Parameters** (optional)
* **Step 7:** Choose the **Output**
* **Step 8:** Run the flow and read the **Last run**

***

#### ➕ Step 1: Add the node

> Inside a flow, go to **Actions**, search for **OpenAI** and drag the OpenAI AI node onto the canvas. Connect the arrow from the previous step to the node, then click the node to open its settings.

The settings are grouped in sections, top to bottom: **Connection**, **Model**, **Prompt**, **Attachments**, **Parameters** and **Output**. In any text field, type `{` to insert a variable from a previous step.

***

#### 🔌 Step 2: Choose the Connection — who pays for the model

> Open the **Connection** dropdown. There are two ways to run the node:

* **Dapta AI** — the default. It works out of the box and uses your [Dapta credits](/my-account/how-credits-work-in-dapta.md). Credits are metered on the model that actually answers, based on how much text it reads and writes.
* **My own credential** — runs on your own OpenAI account. OpenAI bills that usage to you, and it doesn't use your Dapta credits. Pick your credential in the field that appears, or add a new one: the **OpenAI credential** dialog asks for a **Name** and your **Secret key**, which is stored encrypted with your workspace credentials. Create the key in [the OpenAI Platform](https://platform.openai.com/api-keys).

The line under the dropdown tells you how the node is billed with the model you chose.

***

#### 🧠 Step 3: Pick a Model

> Open the **Model** dropdown and choose the model that writes the answer.

Models are grouped into **Recommended**, **Open source** (GPT-OSS models hosted by Dapta, usually the lowest-cost option) and **Advanced** (OpenAI's most capable models — the heaviest ones use many more credits). The node's default model, **GPT-5.4**, is marked **Default**.

Each model shows three meters — **reasoning**, **speed** and **price** (more bars mean smarter, faster or more credits per run) — and, once selected, whether it supports **Reasoning** and **Structured output**. The options in the next steps adapt to what the selected model can do.

{% hint style="warning" %}
If a model you saved is retired, the node says so and asks you to pick a replacement. Dapta never switches your model without telling you.
{% endhint %}

***

#### ✍️ Step 4: Write your Prompt

> In **Prompt**, tell the AI what to do in your own words. Type `{` to insert a variable from a previous step; **Shift+Enter** adds a new line.

For example: *"Classify this message as sales, support or other, and explain why in one sentence: {{message}}"*.

Two optional extras sit below the prompt:

* **System instruction (optional)** — a role or rules the AI always follows, such as *"You are a friendly support agent"*. Most flows only need the prompt.
* **Add message** — add an example exchange to teach the AI the style and format you want. Set each message's **Role** to **User** (you) or **Model** (an example answer from the AI) and write its **Content**.

***

#### 📎 Step 5: Add Attachments (optional)

> In **Attachments**, paste a link to a file — a Google Drive or Google Docs link works — or insert a variable that holds a link from a previous step. Click **Add attachment** to add another file.

* Up to **5 files per run**, **15 MB** each and **20 MB** in total.
* Supported files: **PDF**, **Word (.docx)**, **PNG**, **JPG**, **WebP** and **GIF**. Save an older `.doc` file as `.docx` or PDF first.
* Use a direct link to the file. A link that opens a preview page, or a temporary link that has expired, can't be read.

{% hint style="info" %}
Links written inside the prompt are read as text, not opened. To have the AI read a file, add it in **Attachments**.
{% endhint %}

***

#### 🎛️ Step 6: Fine-tune the Parameters (optional)

> Expand **Parameters** only if you need to. The defaults work well for most flows.

* **Creativity** — how varied the answer is (the model's temperature). GPT-5 models don't accept it, so the slider only appears for models that do, such as the GPT-OSS models.
* **Max answer length** — the longest answer the model may write, in tokens (a token is roughly a short word). Leave it empty to let the model use its full length, which is recommended.
* **Reasoning effort** — GPT-5 models think before answering. Turn it on and pick **None**, **Low**, **Medium** (the default), **High** or **Extra high**: higher effort gives smarter answers, but is slower and uses more credits.
* **Authorize fallback** — available with **Dapta AI** only. If the model is busy or fails, the node retries automatically with the **Backup model** you choose, which can come from any AI lab available on Dapta. Credits only meter the model that actually ran.

***

#### 📤 Step 7: Choose the Output

> Open the **Output** dropdown to decide how the answer comes back.

| Output                 | What the flow receives                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ---------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **JSON (Recommended)** | The default. The answer arrives already converted to JSON, with no extra Code node needed.                                                                                                                                                                                                                                                                                                                                                                                          |
| **Text**               | The answer as plain text. The simplest option, and it works with every model.                                                                                                                                                                                                                                                                                                                                                                                                       |
| **Structured**         | Ready-to-use fields you define. Click a template under **Start from a template** — **Extract contact info**, **Parse JSON**, **Classify** or **Extract list** — or build your own under **Fields**: give each field a name, a type (**Text**, **Number**, **Yes / no**, **List**, **Group of fields** or **One of a list**), mark it **Required** if the AI must always fill it, and add a **+ note** to explain it. Turn on **Returns a list** when you expect several items back. |

JSON and Structured are only available with models that support **Structured output**.

With **JSON**, **If the JSON is invalid** decides what happens when the model returns broken JSON: **Return empty (null)** (the default — the flow continues with an empty value), **Return the raw text** (the flow continues with the unconverted text) or **Stop with an error** (the node fails and your flow's error handling takes over).

**Response detail** sets how much of the response the flow receives:

* **Answer + details** — the default. The flow receives `answer`, `json`, `usage` and `costs.credits`, the same fields for every model. Type `{` in any later field to pick them.
* **Raw response** — the provider's full response, unchanged. Its fields vary by provider.

***

#### ▶️ Step 8: Run the flow and read the Last run

> Save the flow and run it. After a run, the node shows a **Last run** section.

**Last run** shows the **Model** that actually answered (with fallback on, it may be the backup model), the **Provider**, **Tokens in**, **Tokens out**, **Cached** tokens (cached text costs fewer credits) and the **Credits** the run used. It also tells you when the run used the fallback model or when the model stopped before finishing.

***

#### 🛠️ Troubleshooting

| Message                                       | What to do                                                                                                       |
| --------------------------------------------- | ---------------------------------------------------------------------------------------------------------------- |
| The AI model is busy or unavailable right now | Usually temporary on the provider's side. Try again in a moment, or turn on **Authorize fallback**.              |
| This node's API key isn't working             | Check the credential connected under **My own credential**: the key may be missing, empty or rejected by OpenAI. |
| The model's answer wasn't valid JSON          | Try again, change **If the JSON is invalid**, or switch **Output** to **Text**.                                  |
| The model stopped before finishing            | Raise **Max answer length** or adjust the prompt.                                                                |
| That file is too heavy                        | Each file can be up to 15 MB, and 20 MB in total.                                                                |
| That link opens a preview page, not the file  | Use a direct download link.                                                                                      |
| This model can't read files or images         | Pick another model, or remove the attachments.                                                                   |


---

# 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.dapta.ai/flow-studio/nodes/openai-node.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.
