---
title: "OpenAI Connector"
description: "Complete OpenAI integration guide for AI-powered content generation, customer insights, and intelligent marketing automation with Brevo through Tajo."
url: https://tajo.io/docs/connectors/custom/openai/
markdown: https://tajo.io/docs/connectors/custom/openai.md
lang: en-US
robots: noindex
---

# OpenAI Connector

Connector status: Planned Not built yet. Tajo does not run this connector today.

| Source field | Destination field | Sample value |
| --- | --- | --- |
| `record.id` | `source_id` | `record_1042` |
| `record.updated_at` | `updated_at` | `2026-10-18T08:00:00Z` |
| `record.value` | `value` | `sample_value` |

Connect OpenAI to Brevo through Tajo to leverage AI-powered content generation, customer sentiment analysis, intelligent segmentation, and predictive analytics for your marketing automation workflows.

## Overview

| Property | Value |
| --- | --- |
| **Platform** | OpenAI |
| **Category** | AI / ML (Custom) |
| **Setup Complexity** | Medium |
| **Official Integration** | No |
| **Data Synced** | Content, Embeddings, Insights, Predictions |
| **Auth Method** | API Key (Bearer Token) |

## Features

- **AI content generation** - Generate email subject lines, body copy, and CTAs with GPT models
- **Customer sentiment analysis** - Analyze support tickets and feedback for sentiment scoring
- **Smart segmentation** - Use embeddings to cluster customers by behavior patterns
- **Predictive analytics** - Forecast churn, LTV, and purchase propensity
- **Multi-language content** - Generate marketing content in any supported language
- **Image generation** - Create campaign visuals with DALL-E integration

## Prerequisites

Before you begin, ensure you have:

1. An OpenAI account with API access
2. An API key from the [OpenAI dashboard](https://platform.openai.com/api-keys)
3. A Brevo account with API access
4. A Tajo account with connector permissions
5. Sufficient OpenAI API credits for your expected usage

## Authentication

### API Key Authentication

OpenAI uses Bearer token authentication for all API requests:

```bash
# Set your API keys
export OPENAI_API_KEY=sk-your-api-key
export TAJO_API_KEY=your_tajo_api_key
export BREVO_API_KEY=your_brevo_api_key
```

```javascript
// All requests require the Authorization header
const headers = {
  'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`,
  'Content-Type': 'application/json'
};

// For organization-scoped access
const orgHeaders = {
  ...headers,
  'OpenAI-Organization': process.env.OPENAI_ORG_ID,
  'OpenAI-Project': process.env.OPENAI_PROJECT_ID
};
```

API Key Security

Never expose your OpenAI API key in client-side code. Always use environment variables and server-side requests. Rotate keys periodically via the OpenAI dashboard.

## Configuration

### Basic Setup

```yaml
connectors:
  openai:
    enabled: true
    model: "gpt-4o"
    embedding_model: "text-embedding-3-small"
    image_model: "dall-e-3"

    features:
      content_generation: true
      sentiment_analysis: true
      smart_segmentation: true
      predictive_analytics: true

    limits:
      max_tokens_per_request: 4096
      max_requests_per_minute: 60
      temperature: 0.7
```

### Content Generation Templates

```yaml
templates:
  email_subject:
    model: "gpt-4o"
    system_prompt: |
      You are an expert email marketer. Generate compelling
      subject lines that drive open rates.
    max_tokens: 100
    temperature: 0.8

  email_body:
    model: "gpt-4o"
    system_prompt: |
      Generate personalized email content based on customer
      data and campaign objectives.
    max_tokens: 2048
    temperature: 0.7
```

## API Endpoints

| Endpoint | Method | Description |
| --- | --- | --- |
| `https://api.openai.com/v1/responses` | POST | Create AI responses (Responses API) |
| `https://api.openai.com/v1/chat/completions` | POST | Generate text completions |
| `https://api.openai.com/v1/embeddings` | POST | Create text embeddings |
| `https://api.openai.com/v1/images/generations` | POST | Generate images |
| `https://api.openai.com/v1/audio/speech` | POST | Text-to-speech generation |
| `https://api.openai.com/v1/audio/transcriptions` | POST | Speech-to-text transcription |
| `https://api.openai.com/v1/moderations` | POST | Content moderation |
| `https://api.openai.com/v1/models` | GET | List available models |

## Code Examples

### Initialize Connector

```javascript
import { TajoClient } from '@tajo/sdk';

const tajo = new TajoClient({
  apiKey: process.env.TAJO_API_KEY,
  brevoApiKey: process.env.BREVO_API_KEY
});

await tajo.connectors.connect('openai', {
  apiKey: process.env.OPENAI_API_KEY,
  defaultModel: 'gpt-4o'
});
```

### Generate Email Content

```javascript
// Generate personalized email subject lines
const response = await fetch('https://api.openai.com/v1/chat/completions', {
  method: 'POST',
  headers: {
    'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`,
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    model: 'gpt-4o',
    messages: [
      {
        role: 'system',
        content: 'Generate 5 compelling email subject lines for a product launch.'
      },
      {
        role: 'user',
        content: `Product: ${product.name}. Target: ${segment.description}.`
      }
    ],
    max_tokens: 200,
    temperature: 0.8
  })
});

const result = await response.json();
const subjectLines = result.choices[0].message.content;
```

### Customer Sentiment Analysis

```javascript
// Analyze customer feedback sentiment
const sentimentAnalysis = await fetch(
  'https://api.openai.com/v1/chat/completions',
  {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'gpt-4o',
      messages: [
        {
          role: 'system',
          content: 'Analyze sentiment. Return JSON: {score: -1 to 1, label: string, topics: string[]}'
        },
        { role: 'user', content: customerFeedback }
      ],
      response_format: { type: 'json_object' },
      max_tokens: 150
    })
  }
);

const sentiment = await sentimentAnalysis.json();
await tajo.contacts.update(email, {
  attributes: { SENTIMENT_SCORE: JSON.parse(sentiment.choices[0].message.content).score }
});
```

### Smart Segmentation with Embeddings

```javascript
// Generate embeddings for customer clustering
const embeddingResponse = await fetch(
  'https://api.openai.com/v1/embeddings',
  {
    method: 'POST',
    headers: {
      'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      model: 'text-embedding-3-small',
      input: customerDescriptions,
      dimensions: 256
    })
  }
);

const embeddings = await embeddingResponse.json();
// Use embeddings for similarity-based customer clustering
```

## Rate Limits

| Model | RPM (Requests/Min) | TPM (Tokens/Min) | RPD (Requests/Day) |
| --- | --- | --- | --- |
| gpt-4o | 500 | 30,000 | 10,000 |
| gpt-4o-mini | 500 | 200,000 | 10,000 |
| text-embedding-3-small | 500 | 1,000,000 | 10,000 |
| dall-e-3 | 5 | N/A | 200 |

Rate Limit Headers

Monitor rate limit headers (`x-ratelimit-remaining-requests`, `x-ratelimit-remaining-tokens`) in API responses to implement proactive throttling and avoid 429 errors.

## Troubleshooting

| Issue | Cause | Solution |
| --- | --- | --- |
| 401 Unauthorized | Invalid API key | Verify key in OpenAI dashboard |
| 429 Rate Limited | Too many requests | Implement exponential backoff |
| 500 Server Error | OpenAI outage | Check status.openai.com and retry |
| Truncated response | max\_tokens too low | Increase max\_tokens parameter |
| Poor content quality | Temperature too high | Lower temperature for consistency |

### Debug Mode

```yaml
connectors:
  openai:
    debug: true
    log_level: verbose
    log_prompts: false  # Don't log prompts in production
    log_usage: true
```

## Best Practices

1. **Cache responses** - Store generated content to reduce API calls and costs
2. **Use structured outputs** - Request JSON responses for reliable parsing
3. **Implement retry logic** - Handle rate limits with exponential backoff
4. **Monitor token usage** - Track consumption to control costs
5. **Use appropriate models** - Use gpt-4o-mini for simple tasks, gpt-4o for complex ones
6. **Validate outputs** - Always validate AI-generated content before sending to customers

## Security

- **Bearer token auth** - API keys transmitted via Authorization header
- **Server-side only** - Never expose API keys in client-side code
- **Key rotation** - Rotate API keys regularly via OpenAI dashboard
- **Usage monitoring** - Set spending limits in OpenAI billing settings
- **Content moderation** - Use the Moderations API to filter unsafe content
- **Data privacy** - Review OpenAI’s data usage policies for your use case

## Related Resources

- [Brevo Connector](https://tajo.io/docs/connectors/marketing/brevo)
- [Customer Sync Skill](https://tajo.io/docs/skills/data-sync/customer-sync)
- [Email Marketing Skills](https://tajo.io/docs/skills/email-marketing)
- [OpenAI API Reference](https://platform.openai.com/docs/api-reference)

## Open-Source Implementation Map

This section is derived from official or public repository material discovered for the OpenAI connector. Use it as the engineering companion to the setup guide above: it shows where the API surface lives, what implementation assets exist, and how Tajo should translate them into reliable Brevo sync behavior.

### Repository Snapshot

| Repository | Commit | Languages / formats | Files |
| --- | --- | --- | --- |
| [openai/openai-openapi](https://github.com/openai/openai-openapi) | e1cb7a8 | license (1), Markdown (1) | 2 |

### Integration Shape

```mermaid
graph LR
  Source["OpenAI API / repository"] --> Auth["Auth and scopes"]
  Source --> Objects["Objects, events, and schemas"]
  Auth --> Tajo["Tajo connector runtime"]
  Objects --> Tajo
  Tajo --> Brevo["Brevo contacts, attributes, lists, campaigns"]
  Tajo --> Ops["Backfill, cursor, retries, logs"]
```

### What To Reuse

- OpenAPI spec for the OpenAI API
- The most recent OpenAPI specification for the OpenAI API can be found here:
- [https://app.stainless.com/api/spec/documented/openai/openapi.documented.yml](https://app.stainless.com/api/spec/documented/openai/openapi.documented.yml)
- To see the most recent manually updated version of the OpenAPI spec, refer to
- this branch:

### Tajo Revamp Checklist

- Keep authentication setup aligned with the vendor docs and the public repository’s current API shape.
- Map primary resources into explicit Tajo sync objects with stable external IDs.
- Prefer cursor-based or updated-at incremental sync where the API exposes it; otherwise document the fallback.
- Treat webhook handlers as idempotent and replay-safe, especially for order, contact, ticket, and campaign events.
- Capture pagination, rate limits, retry headers, and partial-failure behavior in connector smoke tests.
- Keep examples small and runnable against sandbox or test-mode accounts.

### Sources

- [openai/openai-openapi](https://github.com/openai/openai-openapi)
- [Vendor documentation](https://platform.openai.com/docs/api-reference)
