OpenAI कनेक्टर
अपने marketing automation workflows के लिए AI-powered content generation, customer sentiment analysis, intelligent segmentation, और predictive analytics का लाभ उठाने हेतु Tajo के माध्यम से OpenAI को Brevo से कनेक्ट करें।
अवलोकन
| 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) |
विशेषताएं
- AI content generation - GPT models के साथ email subject lines, body copy, और CTAs generate करें
- Customer sentiment analysis - sentiment scoring के लिए support tickets और feedback का विश्लेषण करें
- Smart segmentation - behavior patterns द्वारा customers को cluster करने के लिए embeddings का उपयोग करें
- Predictive analytics - churn, LTV, और purchase propensity का पूर्वानुमान लगाएं
- Multi-language content - किसी भी supported language में marketing content generate करें
- Image generation - DALL-E integration के साथ campaign visuals बनाएं
पूर्वावश्यकताएं
शुरू करने से पहले, सुनिश्चित करें कि आपके पास हैं:
- API access वाला एक OpenAI account
- OpenAI dashboard से एक API key
- API access वाला एक Brevo account
- connector permissions वाला एक Tajo account
- अपने अपेक्षित उपयोग के लिए पर्याप्त OpenAI API credits
प्रमाणीकरण
API Key Authentication
OpenAI सभी API requests के लिए Bearer token authentication का उपयोग करता है:
# अपनी API keys सेट करेंexport OPENAI_API_KEY=sk-your-api-keyexport TAJO_API_KEY=your_tajo_api_keyexport BREVO_API_KEY=your_brevo_api_key// सभी requests के लिए Authorization header आवश्यक हैconst headers = { 'Authorization': `Bearer ${process.env.OPENAI_API_KEY}`, 'Content-Type': 'application/json'};
// organization-scoped access के लिएconst orgHeaders = { ...headers, 'OpenAI-Organization': process.env.OPENAI_ORG_ID, 'OpenAI-Project': process.env.OPENAI_PROJECT_ID};API Key Security
अपनी OpenAI API key को कभी भी client-side code में expose न करें। हमेशा environment variables और server-side requests का उपयोग करें। OpenAI dashboard के माध्यम से keys को समय-समय पर rotate करें।
कॉन्फ़िगरेशन
बेसिक सेटअप
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.7Content Generation Templates
templates: email_subject: model: "gpt-4o" system_prompt: | आप एक expert email marketer हैं। ऐसी compelling subject lines generate करें जो open rates बढ़ाएं। max_tokens: 100 temperature: 0.8
email_body: model: "gpt-4o" system_prompt: | customer data और campaign objectives के आधार पर personalized email content generate करें। max_tokens: 2048 temperature: 0.7API Endpoints
| Endpoint | Method | विवरण |
|---|---|---|
https://api.openai.com/v1/responses | POST | AI responses बनाएं (Responses API) |
https://api.openai.com/v1/chat/completions | POST | text completions generate करें |
https://api.openai.com/v1/embeddings | POST | text embeddings बनाएं |
https://api.openai.com/v1/images/generations | POST | images generate करें |
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 | उपलब्ध models list करें |
कोड उदाहरण
कनेक्टर शुरू करें
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'});Email Content Generate करें
// personalized email subject lines generate करें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
// 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 }});Embeddings के साथ Smart Segmentation
// customer clustering के लिए embeddings generate करें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();// similarity-आधारित customer clustering के लिए embeddings का उपयोग करें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
API responses में rate limit headers (x-ratelimit-remaining-requests, x-ratelimit-remaining-tokens) को monitor करें ताकि सक्रिय throttling लागू कर सकें और 429 errors से बच सकें।
समस्या निवारण
| समस्या | कारण | समाधान |
|---|---|---|
| 401 Unauthorized | अमान्य API key | OpenAI dashboard में key सत्यापित करें |
| 429 Rate Limited | बहुत अधिक requests | exponential backoff लागू करें |
| 500 Server Error | OpenAI outage | status.openai.com जांचें और retry करें |
| Truncated response | max_tokens बहुत कम | max_tokens parameter बढ़ाएं |
| खराब content quality | Temperature बहुत अधिक | consistency के लिए temperature कम करें |
Debug Mode
connectors: openai: debug: true log_level: verbose log_prompts: false # production में prompts log न करें log_usage: trueसर्वोत्तम प्रथाएं
- Responses cache करें - API calls और costs कम करने के लिए generated content store करें
- Structured outputs का उपयोग करें - विश्वसनीय parsing के लिए JSON responses का अनुरोध करें
- Retry logic लागू करें - exponential backoff के साथ rate limits संभालें
- Token usage monitor करें - costs नियंत्रित करने के लिए consumption ट्रैक करें
- उपयुक्त models का उपयोग करें - सरल कार्यों के लिए gpt-4o-mini, जटिल कार्यों के लिए gpt-4o का उपयोग करें
- Outputs validate करें - customers को भेजने से पहले हमेशा AI-generated content validate करें
सुरक्षा
- Bearer token auth - API keys Authorization header के माध्यम से transmit होती हैं
- Server-side only - API keys को कभी भी client-side code में expose न करें
- Key rotation - OpenAI dashboard के माध्यम से API keys को नियमित रूप से rotate करें
- Usage monitoring - OpenAI billing settings में spending limits सेट करें
- Content moderation - unsafe content filter करने के लिए Moderations API का उपयोग करें
- Data privacy - अपने use case के लिए OpenAI की data usage policies की समीक्षा करें