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:
- Create an OpenAI account at OpenAI Platform.
- Navigate to the API Keys section.
- Click Create new secret key.
- 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:
- Create an Azure account and subscribe to Azure OpenAI Service.
- Deploy a model in the Azure OpenAI Studio.
- 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.
- Required Information: API Key and Base URL (e.g.,
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
| Parameter | Requirement | Description | Example |
|---|---|---|---|
| messages | Mandatory | Array of messages with roles and content. | [{"role": "user", "content": "Hello"}] |
| temperature | Optional | Controls response randomness (0-1). | 0.7 |
| returnAsJson | Optional | Format response as JSON. | true |
| sampleJson | Optional | Example JSON structure for response. | {"answer": "string", "confidence": "number"} |
Message Structure
Messages in the messages array must follow this structure:
| Field | Description | Example |
|---|---|---|
| role | Message sender role. | "system" or "user" |
| content | Text content of the message. | "What is the weather today?" |
Multimodal Message (with images): The message object can include image fields for multimodal inputs:
| Field | Description | Example |
|---|---|---|
| mimeType | MIME type of the image. | "image/jpeg" |
| fileData | Image URL. | "https://example.com/image.jpg" |
Supported Image Types:
- JPEG (.jpeg, .jpg)
- PNG (.png)
Updated about 20 hours ago
