# ChatGPT API with Dualite

### Overview

OpenAI has created some of the most sophisticated and commonly used language models, such as GPT-4 and GPT-4o, which can generate, summarise, translate, and reason over a wide range of inputs, including text, pictures, and code. Integrating OpenAI into Dualite Alpha allows you to create responsive, intelligent, and user-centred apps that combine Alpha's no-code design and automation with OpenAI's strong generative AI.This article will show you how to integrate OpenAI into your Alpha projects to boost use cases like as smart forms, chatbots, document analysers, creative tools, and more.

### Why OpenAI?

OpenAI models are known for:

* Exceptional natural language understanding and generation.
* Strong coding and logic capabilities.
* Ability to handle multimodal inputs (text, images, audio in some versions like GPT-4o).
* Robust API ecosystem with reliable support and documentation.
* Ideal for building intelligent user flows, dynamic content generation, and context-aware automation.

### Integrating OpenAI in Dualite Alpha

Before starting, make sure you have:

* Access to OpenAI’s developer platform.
* An active OpenAI API key (from <https://platform.openai.com>).

#### Step 1: Get Access to OpenAI

Visit [OpenAI’s platform](https://platform.openai.com/), sign in with your OpenAI account, and create an API key. GPT-4o is generally recommended for rich multimodal and real-time applications.

* If you are not being able to locate it, go to <https://platform.openai.com/api-keys>, login and create a project.

<figure><img src="https://3249760354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FV8GfqSvH6vHDgFIKWOOu%2Fuploads%2FL8cdVKF8EZ6szuCzPCyv%2FScreenshot%202025-07-01%20at%2010.33.05%E2%80%AFPM.png?alt=media&#x26;token=694d70a3-ed30-4567-a69f-8dfba71f8b92" alt=""><figcaption></figcaption></figure>

<figure><img src="https://3249760354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FV8GfqSvH6vHDgFIKWOOu%2Fuploads%2FfpSe70OLSfUcwEXtsxuC%2FScreenshot%202025-07-01%20at%2010.28.08%E2%80%AFPM.png?alt=media&#x26;token=9e4b3564-92f1-4f13-b56b-a7ae41278fb0" alt=""><figcaption></figcaption></figure>

#### Step 2: Write Your Prompt in Alpha

Start by describing the app you want to build and make sure to include:

* What the app does (its core functionality)
* The UI elements you need (e.g., input fields, buttons, output areas)
* The type of AI integration (e.g., text generation, summarization, classification)
* Any specific prompts or behaviors you want the AI to follow

Alpha will use this prompt to automatically generate the app interface and backend logic.

#### Step 3: Add the API Key in AlphaOnce your app is generated:

* Open the "Code" section in Alpha
* Navigate to the <kbd>.env</kbd> file
* Paste your OpenAI API Key in the appropriate variable

<figure><img src="https://3249760354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FV8GfqSvH6vHDgFIKWOOu%2Fuploads%2F7Uu8NkRnjPyM8G2oLaVX%2FScreenshot%202025-07-02%20at%201.22.27%E2%80%AFPM.png?alt=media&#x26;token=e765799d-82cd-41ae-9d0d-a6e9bbc5b7e7" alt=""><figcaption></figcaption></figure>

### Example: Build a Smart Email Generator

Let’s build a tool that helps users instantly generate professional emails based on a brief input.

#### Step-by-Step:

#### Step1: Write your prompt in Alpha.

*For example:* Create a modern UI web app called "Smart Email Generator" that helps users write professional emails using OpenAI. The app should have:

1. A short text input labeled "Describe the Situation" where users enter the context of the email (e.g., “Client asking for a refund”).
2. A dropdown menu labeled "Select Tone" with options: Formal, Friendly, Apologetic, Assertive.
3. A button labeled "Generate Email" that triggers the OpenAI API.
4. A text area below that displays the AI-generated email response.
5. Use GPT-4o to generate the email using a prompt like:

<figure><img src="https://3249760354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FV8GfqSvH6vHDgFIKWOOu%2Fuploads%2FuE8Iaoi91uhCpZp01PgS%2FScreenshot%202025-07-02%20at%2011.22.25%E2%80%AFAM.png?alt=media&#x26;token=f3f75f5d-69ba-408e-b687-b752f49b383b" alt=""><figcaption></figcaption></figure>

After Alpha has created your tool, it will propose some Setup Instructions and require you to add the API Key.

<figure><img src="https://3249760354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FV8GfqSvH6vHDgFIKWOOu%2Fuploads%2FjXrabuJVC5yo5UauvOO4%2FScreenshot%202025-07-02%20at%2011.24.17%E2%80%AFAM.png?alt=media&#x26;token=7ac3ad8c-6912-41bc-b15b-6f9873e29ad1" alt=""><figcaption></figcaption></figure>

#### Step 2: Copy your API Key

Go to <https://platform.openai.com/api-keys> and copy the API Key you generate.

<figure><img src="https://3249760354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FV8GfqSvH6vHDgFIKWOOu%2Fuploads%2F4DdnxQdSmhj3JuMgT8BN%2FScreenshot%202025-07-02%20at%2011.25.58%E2%80%AFAM.png?alt=media&#x26;token=32f9092f-d0c5-4b91-b3d9-376efddd4164" alt=""><figcaption></figcaption></figure>

#### Step 3: Paste your API Key

\
Go to code and .env to paste your API Key

<figure><img src="https://3249760354-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FV8GfqSvH6vHDgFIKWOOu%2Fuploads%2FXm72ngkWAnx1BAQ6hqHq%2FScreenshot%202025-07-02%20at%2011.24.52%E2%80%AFAM.png?alt=media&#x26;token=9fcf8535-3681-4dd3-8fde-add62f574d59" alt=""><figcaption></figcaption></figure>

### Conclusion

Bringing OpenAI into your Dualite Alpha workflow opens up endless possibilities. Whether you're building AI assistants, automating content, or analyzing documents, OpenAI provides a versatile, high-performance engine that enhances the power and flexibility of your no-code app.
