Open AI

Overview

The OpenAI connector enables your AI Colleagues to integrate with OpenAI's powerful AI models, facilitating automated text generation, content creation, and intelligent response workflows.

OpenAI is a leading artificial intelligence company that provides advanced language models including GPT-4, GPT-4o, and GPT-5 series. The OpenAI connector allows Leena AI to leverage these models for text generation, content analysis, and AI-powered automation workflows seamlessly.

API Details

Leena AI integrates with OpenAI via REST APIs.

Documentation link: https://platform.openai.com/docs/api-reference

Setup

The OpenAI connector uses API Key authentication to securely connect with OpenAI's services. Additionally, Azure OpenAI authentication is supported for enterprise deployments.


Prerequisites

Before setting up the OpenAI connector, ensure you have:

  • An active OpenAI account at platform.openai.com
  • Access to OpenAI API Keys section in your account settings
  • Sufficient API credits or an active billing plan
  • Access to your Leena AI workspace with connector management permissions
  • For Azure OpenAI: Access to Azure Portal with Azure OpenAI Service enabled

Get credentials

Here is how to create an API key in OpenAI Platform:

  1. Log in to OpenAI Platform (Navigate to platform.openai.com and sign in with your OpenAI account).
  2. Navigate to API Keys:
    1. Click on your profile icon at the top-right corner of the page
    2. Select "View API Keys" or navigate directly to the API keys section
  3. Create API Key:
    1. Click on "+ Create new secret key" button
    2. Enter a descriptive name for your API key (e.g., "Leena AI Integration")
    3. Click "Create secret key"
  4. Copy and Save Credentials:
    1. Important: Copy the API key immediately as it will only be displayed once
    2. Store the key securely in a password manager or secure location
    3. The API key format starts with "sk-" followed by alphanumeric characters
  5. Set Up Billing (if required):
    1. Navigate to Settings > Billing
    2. Add a payment method if not already configured
    3. Ensure you have sufficient credits for API usage

Add connection

Here is how to add a connection on Leena AI:

  1. Log in to your Leena AI workspace
  2. Navigate to Settings > Integrations
  3. Search for "OpenAI" and select it from the list to add its new connector
  4. Start configuring the connector
    1. Model: Select the OpenAI model to use (Pre-filled options include gpt-4o, gpt-4, gpt-4o-mini, gpt-35-turbo-16k, gpt-4.1-mini, gpt-4.1-nano, gpt-4o-search-preview, gpt-5-mini, gpt-5-nano, gpt-5)
    2. API Version: Select the API version (Options: 2024-10-21, 2024-06-01)
    3. Auth Type: Select the authentication type:
      • API Key: For direct OpenAI API authentication
      • Azure API Key: For Azure OpenAI Service authentication
      • Azure Leena API Key: For Azure OpenAI through Leena's managed service
    4. API Key: Enter your OpenAI API key (for API Key auth type)
    5. Base URL: Enter the Azure OpenAI endpoint URL (for Azure auth types, e.g., https://your-resource.openai.azure.com)
  5. Save Configuration
    1. Click Save to store the connector configuration
    2. The connector will validate the credentials
    3. Upon successful validation, the connector will be active and ready to use

Actions

The following actions are supported for the OpenAI connector:

Generate Text

Generates text content using OpenAI's language models. The Agent can leverage the skill (workflow), which has been designed to generate intelligent text responses, once the user raises a query requiring AI-powered content generation. Here are some common use cases:

  • Content Creation: Generate articles, summaries, or documentation
  • Response Generation: Create automated responses for customer queries
  • Data Analysis: Analyze and summarize text content
  • Translation: Translate content between languages
  • Code Assistance: Generate or explain code snippets
  • Creative Writing: Generate creative content like stories or marketing copy

Input Parameters

Here are the input parameters required to set up this action:

Mandatory

NameDescription
MessagesArray of message objects containing the conversation context with role and content for each message

Optional

NameDescription
Enable Web SearchToggle to enable web search capability for retrieving real-time information (available for search preview models)
TemperatureControls randomness in output generation (0-2). Lower values produce more focused responses, higher values more creative. Default: 0
Return As JSONToggle to instruct the model to return response in JSON format
Sample JSONWhen Return As JSON is enabled, provide a sample JSON structure for the expected response format
Web Search - Context SizeAmount of search context to include. Options: Low, Medium, High. Default: Medium
Web Search - User Location TypeType of user location for search context. Options: Approximate
Web Search - CityFree text input for the city of the user (e.g., San Francisco)
Web Search - CountryThe two-letter ISO country code of the user (e.g., US)
Web Search - RegionFree text input for the region of the user (e.g., California)
Web Search - TimezoneThe IANA timezone of the user (e.g., America/Los_Angeles)

Message Object Parameters

NameDescription
RoleThe role of the message author. Options: system, user
ContentThe text content of the message
MIME TypeThe MIME type of the attached file (optional, for image inputs)
File Data (Url)URL of an image file to include with the message. Supported formats: .jpeg, .jpg, .png

Here is a sample JSON input:

// Basic Text Generation

{
  "payload": {
    "temperature": 0.7,
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful assistant that provides concise and accurate information."
      },
      {
        "role": "user",
        "content": "Explain the benefits of cloud computing in 3 bullet points."
      }
    ]
  }
}

// Generate Text with JSON Response

{
  "payload": {
    "temperature": 0.5,
    "messages": [
      {
        "role": "system",
        "content": "You are a data extraction assistant."
      },
      {
        "role": "user",
        "content": "Extract the key information from this text: John Smith works at Acme Corp as a Senior Engineer since 2020."
      }
    ]
  },
  "returnAsJson": true,
  "sampleJson": {
    "name": "",
    "company": "",
    "position": "",
    "startYear": ""
  }
}

// Text Generation with Image Input

{
  "payload": {
    "temperature": 0.3,
    "messages": [
      {
        "role": "user",
        "content": "Describe what you see in this image.",
        "mimeType": "image/jpeg",
        "fileData": "https://example.com/images/sample-chart.jpg"
      }
    ]
  }
}

// Text Generation with Web Search Enabled

{
  "webSearchEnabled": true,
  "payload": {
    "messages": [
      {
        "role": "user",
        "content": "What are the latest developments in renewable energy technology?"
      }
    ],
    "webSearchOptions": {
      "searchContextSize": "medium",
      "userLocation": {
        "type": "approximate",
        "approximate": {
          "city": "New York",
          "country": "US",
          "region": "New York",
          "timezone": "America/New_York"
        }
      }
    }
  }
}

// Multi-turn Conversation

{
  "payload": {
    "temperature": 0.7,
    "messages": [
      {
        "role": "system",
        "content": "You are a helpful HR assistant for employee queries."
      },
      {
        "role": "user",
        "content": "What is the company's leave policy?"
      },
      {
        "role": "system",
        "content": "Employees are entitled to 20 days of paid leave per year, plus public holidays."
      },
      {
        "role": "user",
        "content": "How do I apply for leave?"
      }
    ]
  }
}

Response

Upon successful text generation, the action returns the generated content including:

  • Response ID
  • Model used for generation
  • Generated text content in the choices array
  • Parsed JSON (if returnAsJson was enabled and response was valid JSON)
  • Finish reason indicating why the model stopped generating
  • Usage statistics (tokens used)