Open AI

Overview

The OpenAI connector enables you to configure the OpenAI integration to access powerful GPT models for text generation and processing. It supports both OpenAI and Azure OpenAI deployments.

The OpenAI connector enables you to:

  • Generate text responses using GPT models.
  • Process images alongside text prompts.
  • Format responses as structured JSON.
  • Use various GPT model versions.
  • Choose between OpenAI and Azure OpenAI endpoints.
  • Handle complex conversations with context.

Setup

Prerequisites

Before setting up the OpenAI connector, ensure you have:

  • An OpenAI account or Azure subscription with OpenAI Service.
  • API key from OpenAI or Azure.
  • Understanding of token usage and rate limits.

Get Credentials

The OpenAI connector offers three authentication methods:

Option 1: OpenAI API Key

Use standard OpenAI platform authentication:

  1. Create an OpenAI account at OpenAI Platform.
  2. Navigate to the API Keys section.
  3. Click Create new secret key.
  4. Copy your API key for configuration.
    • Configuration: Paste your OpenAI API key in the configuration field; no additional configuration is needed.

Option 2: Azure OpenAI API Key

Use Azure-hosted OpenAI models:

  1. Create an Azure account and subscribe to Azure OpenAI Service.
  2. Deploy a model in the Azure OpenAI Studio.
  3. Obtain your API key and endpoint URL from the Azure portal.
    • Required Information: API Key and Base URL (e.g., https://your-resource-name.openai.azure.com).
    • Configuration: Enter your Azure API key, provide your Azure OpenAI endpoint URL, and select the appropriate API version.

Option 3: Leena AI Azure Auth Key

Use Leena AI's pre-configured Azure OpenAI credentials:

  • No additional configuration required.
  • Simplified setup process.
  • Managed by Leena AI platform.
  • Automatically uses Leena AI's credentials.

Add Connection

Step 1: Choose Authentication Method

During connector setup, select one of the following:

  • OpenAI API Key: Direct OpenAI platform access.
  • Azure OpenAI API Key: Azure-hosted models.
  • Leena AI Azure Auth Key: Managed authentication.

Step 2: Select Model and API Version

You must select the model and API version to use:

Available Models:

  • gpt-4o: Most capable model with vision support.
  • gpt-4: Powerful model for complex tasks.
  • gpt-4o-mini: Efficient version with lower cost.
  • gpt-3.5-turbo-16k: Efficient model with 16k token context.

API Versions:

  • 2024-10-21: Latest version with all features.
  • 2024-06-01: Previous stable version.

Step 3: Test Connection and Save

Actions

The OpenAI connector provides a single, powerful action for text generation with multimodal capabilities.

Generate Text

Generates text responses using the configured GPT model.

Input Parameters

ParameterRequirementDescriptionExample
messagesMandatoryArray of messages with roles and content.[{"role": "user", "content": "Hello"}]
temperatureOptionalControls response randomness (0-1).0.7
returnAsJsonOptionalFormat response as JSON.true
sampleJsonOptionalExample JSON structure for response.{"answer": "string", "confidence": "number"}

Message Structure

Messages in the messages array must follow this structure:

FieldDescriptionExample
roleMessage sender role."system" or "user"
contentText content of the message."What is the weather today?"

Multimodal Message (with images): The message object can include image fields for multimodal inputs:

FieldDescriptionExample
mimeTypeMIME type of the image."image/jpeg"
fileDataImage URL."https://example.com/image.jpg"

Supported Image Types:

  • JPEG (.jpeg, .jpg)
  • PNG (.png)