# OpenAI Integration

## Introduction

FLUX provides integration with the OpenAI API, enabling you to create elements that leverage artificial intelligence capabilities within your workflows.

## Overview

The OpenAI integration is implemented through two key components:

- **OpenAI API Profile** – Provides the configuration and credentials needed to connect with OpenAI services
- **OpenAI Element Group** – Contains specialized elements that interact with the OpenAI API to send questions and receive AI-generated responses

You can view the profile configuration here: [OpenAI API Profile Example](https://flux-dev.zequenze.com/admin/inventory/profile/7)

## Available OpenAI Elements

FLUX includes several pre-built elements that demonstrate OpenAI integration capabilities:

### Python Helper
- **Purpose**: Generates Python code to extract variables from files
- **Use Case**: Used by other models to automatically create Python code that extracts variables from test data into a dictionary format
- **Link**: [View Element](https://flux-dev.zequenze.com/admin/inventory/element/25)

### TTP Helper
- **Purpose**: Generates TTP (Template Text Parser) models from test data
- **Use Case**: Used by other models to create TTP templates capable of extracting variables from test data into a dictionary format
- **Link**: [View Element](https://flux-dev.zequenze.com/admin/inventory/element/24)

### JSON Query
- **Purpose**: Performs complex queries on JSON data structures
- **Use Case**: Used by [PublicElementConfig](https://docs.zequenze.com/books/flux/page/publicelementconfig) to execute advanced JSON queries
- **Link**: [View Element](https://flux-dev.zequenze.com/admin/inventory/element/27)

## Using OpenAI Elements in Your Code

To integrate OpenAI elements into your code, follow these steps:

1. **Locate the Element** – Search for the Element that contains your desired OpenAI model
2. **Invoke the Function** – Call `make_question_to_openai_element()` with your question as the second parameter
3. **Receive the Response** – The function returns the OpenAI-generated answer

### How It Works

The `make_question_to_openai_element()` function executes an OpenAI API call using:
- The base model context
- Previous conversation history (if any)
- Your current question

The function then returns the AI-generated response for use in your application.

### Example Implementation

[![](https://docs.zequenze.com/uploads/images/gallery/2026-02/iWIUq197g5PSuvPW-tmppggrl785.png)](https://docs.zequenze.com/uploads/images/gallery/2023-07/vFbQQhAt7HyzQvT8-image-1689561870741.png)

## Additional Resources

For detailed information on creating custom models with OpenAI integration capabilities, refer to the [Models](https://docs.zequenze.com/books/flux/page/models) documentation page.