> ## Documentation Index
> Fetch the complete documentation index at: https://docs.elementum.io/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenAI Setup

> Configure OpenAI as your AI provider for language model services

## Overview

OpenAI provides language models including o3, o4-mini, and GPT-4 Omni. This guide walks you through setting up OpenAI as an AI Provider in Elementum.

<Info>
  **Prerequisites**: You'll need an OpenAI account with API access. Individual accounts and organization accounts are both supported.
</Info>

## Step 1: Get Your OpenAI API Key

### Create an OpenAI Account

1. **Visit OpenAI Platform**

   * Go to [platform.openai.com](https://platform.openai.com)
   * Sign up for an account or log in to your existing account

2. **Set Up Billing**
   * Navigate to **Settings** → **Billing**
   * Add a payment method to enable API access
   * Consider setting up usage limits to control costs

### Generate Your API Key

<Steps>
  <Step title="Access API Keys">
    In your OpenAI dashboard, navigate to **API Keys** in the left sidebar
  </Step>

  <Step title="Create New Key">
    Click **Create new secret key**

    Give your key a descriptive name like "Elementum Integration"
  </Step>

  <Step title="Copy and Store">
    **Critical**: Copy the API key immediately and store it securely

    You won't be able to view it again after closing the dialog
  </Step>

  <Step title="Set Permissions (Optional)">
    If using an organization account, you can set specific permissions for the key

    Ensure the key has access to the models you plan to use
  </Step>
</Steps>

<Warning>
  Never share your API key or commit it to version control. Store it in a secure location like a password manager.
</Warning>

## Step 2: Configure OpenAI in Elementum

### Add the Provider

1. In Elementum, go to **Organization Settings** and select the **Providers** tab
2. Click **+ Provider** and select **OpenAI** from the provider options
3. Configure the provider settings:

<Tabs>
  <Tab title="Basic Configuration">
    **Provider Name**: Enter a descriptive name (e.g., "OpenAI Production")

    **API Key**: Paste your OpenAI API key

    **Endpoint URL** (Optional): Custom endpoint URL for Azure OpenAI or other OpenAI-compatible APIs. Leave blank to use the default OpenAI API endpoint.

    **CloudLink**: Select which CloudLinks can access models from this provider. Leave as "All CloudLinks" unless you need to restrict access.

    <Note>
      AI services do not support CloudLinks configured with **API** as the connection type. Only CloudLinks connected to a supported data warehouse (Snowflake, BigQuery, or Databricks) can be associated with this provider.
    </Note>
  </Tab>

  <Tab title="Advanced Settings">
    **Request Timeout**: Default is usually sufficient (30 seconds)

    **Max Retries**: Number of retry attempts for failed requests (default: 3)

    **Rate Limiting**: OpenAI handles rate limiting automatically
  </Tab>
</Tabs>

4. Click **Save** to create the provider. Elementum will automatically validate your API key — look for a green checkmark indicating a successful connection.

## Step 3: Create your first AI service

With your OpenAI provider configured, create an AI Service that uses an OpenAI model. See [AI Services](/ai-agents/ai-services) for the full walkthrough, including LLM service configuration, assignment, and failover.

For a side-by-side comparison of the OpenAI models available in Elementum—including recommendations for daily tasks vs. complex reasoning—see [AI Models](/ai-agents/ai-models).

<Info>
  **Note**: Embeddings for AI Search are handled exclusively through Snowflake Cortex. OpenAI models are used for LLM services only.
</Info>

## Usage Guidelines

### Cost Management

OpenAI charges based on token usage. To manage costs:

<Tabs>
  <Tab title="Monitor Usage">
    * Monitor usage in the OpenAI dashboard
    * Set up billing alerts
    * Review token consumption regularly
  </Tab>

  <Tab title="Optimize Usage">
    * Use appropriate models for each task
    * Implement context windowing
    * Cache responses when possible
    * Use o4-mini for speed-critical applications
  </Tab>
</Tabs>

### Best Practices

<Accordion title="Model Selection">
  * Use **o4-mini** for most customer support and daily automation tasks
  * Use **o3** for complex reasoning, research, and advanced problem-solving
  * Use **GPT-4 Omni** for content creation and detailed analysis
</Accordion>

<Accordion title="Prompt Engineering">
  * Be specific and clear in your prompts
  * Use system messages for consistent behavior
  * Provide examples for better results
  * For o3, structure complex problems step-by-step
</Accordion>

<Accordion title="Performance Optimization">
  * Choose o4-mini for speed-critical applications
  * Use o3 sparingly for tasks requiring maximum intelligence
  * Implement caching for repeated queries
  * Consider request queuing for high-volume usage
</Accordion>

## Troubleshooting

<Accordion title="Authentication Errors">
  **Symptoms:** API key rejected or unauthorized errors

  **Common Causes:**

  * Invalid or expired API key
  * Insufficient permissions
  * Billing issues

  **Solutions:**

  1. Verify API key is correct and active
  2. Check billing status and payment methods
  3. Ensure key has proper permissions
  4. Regenerate API key if needed
</Accordion>

<Accordion title="Model Not Available">
  **Symptoms:** Desired model doesn't appear in service creation

  **Common Causes:**

  * Account doesn't have access to specific models
  * Regional restrictions
  * Model deprecation

  **Solutions:**

  1. Check OpenAI account tier and access levels
  2. Review model availability in your region
  3. Contact OpenAI support for access issues
  4. Consider alternative models
</Accordion>

<Accordion title="Rate Limit Issues">
  **Symptoms:** Requests being throttled or rejected

  **Common Causes:**

  * Exceeding rate limits
  * High concurrent usage
  * Account tier limitations

  **Solutions:**

  1. Implement exponential backoff
  2. Reduce request frequency
  3. Upgrade account tier if needed
  4. Distribute load across multiple keys
</Accordion>

## Security Considerations

<Tabs>
  <Tab title="API Key Security">
    * Never expose API keys in client-side code
    * Rotate keys regularly
    * Use environment variables for storage
    * Monitor key usage for anomalies
  </Tab>

  <Tab title="Data Privacy">
    * Review OpenAI's current data handling and privacy policies
    * Consider data sensitivity when crafting prompts
    * Implement data sanitization if needed
  </Tab>
</Tabs>

## Advanced Configuration

### Organization Accounts

If you're using an OpenAI organization account, you can centralize API access, billing, and team permissions under a single organization:

* **Organization ID**: Required for organization accounts
* **Member Management**: Control team access through OpenAI dashboard
* **Usage Tracking**: Monitor usage across team members
* **Billing Management**: Centralized billing for the organization

### Custom Endpoints

If you use Azure OpenAI or another OpenAI-compatible API, you can point your provider at a custom endpoint instead of the default OpenAI API:

* **Endpoint URL**: Enter your custom endpoint (e.g., `https://your-resource.openai.azure.com/`)
* **Authentication**: May require additional authentication headers depending on the endpoint
* **Model Names**: Custom model names may be required for non-standard endpoints
* **Rate Limits**: May differ from standard OpenAI limits

## Next Steps

With OpenAI configured as your AI Provider:

<CardGroup cols={2}>
  <Card title="Create AI Services" icon="cog" href="/ai-agents/ai-services">
    Set up specific LLM and embedding services for your workflows
  </Card>

  <Card title="Configure Snowflake Cortex" icon="snowflake" href="/ai-agents/snowflake-cortex-setup">
    Set up Snowflake Cortex for AI Search and embeddings
  </Card>

  <Card title="Build Agents" icon="robot" href="/ai-agents/agents-experience">
    Create conversational AI assistants using OpenAI models
  </Card>

  <Card title="Use AI Actions" icon="zap" href="/workflows/automation-actions-reference">
    Add AI capabilities to your automation workflows
  </Card>
</CardGroup>
