Loading...
Loading...
Loading...
Your sales page builder now has **real OpenAI GPT-4 integration** for AI content analysis. Here's how to set it up:
# 🤖 OpenAI Integration Setup Guide
## 🚀 **Real AI is Now Implemented!**
Your sales page builder now has **real OpenAI GPT-4 integration** for AI content analysis. Here's how to set it up:
---
## 📋 **Setup Steps**
### **1. Get Your OpenAI API Key**
1. Go to [OpenAI Platform](https://platform.openai.com/api-keys)
2. Log in to your OpenAI account
3. Click "Create new secret key"
4. Copy the key (starts with `sk-...`)
### **2. Create Environment File**
Create a file called `.env.local` in your project root:
```bash
# OpenAI Configuration
OPENAI_API_KEY=sk-your_actual_api_key_here
# Existing environment variables (if you have them)
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your_nextauth_secret_here
MONGODB_URI=your_mongodb_connection_string_here
```
### **3. Restart Your Development Server**
```bash
npm run dev
```
---
## ✨ **What's New**
### **Real AI Analysis**
- **GPT-4o-mini**: Cost-effective, high-quality analysis
- **Sales Psychology**: Expert-level copywriting feedback
- **Specific Suggestions**: Actionable improvements with examples
- **Smart Scoring**: AI-powered optimization scores
### **Features**
- 🎯 **Headline Analysis**: Emotional impact, clarity, benefit-driven content
- 📞 **CTA Optimization**: Button effectiveness, urgency, placement
- 🎭 **Social Proof Review**: Testimonial strength, credibility markers
- 💡 **Benefit vs Feature Balance**: Psychology-based recommendations
- 🧠 **Persuasion Techniques**: Advanced conversion optimization
- 📊 **Flow Analysis**: Overall sales funnel effectiveness
### **Cost Optimization**
- **Model**: GPT-4o-mini (~$0.0001-0.0003 per analysis)
- **Token Limits**: Optimized for cost efficiency
- **Usage Tracking**: Console logs for monitoring costs
- **Smart Fallback**: Local analysis if API fails
---
## 🔧 **How It Works**
1. **Click "AI Analysis"** in the Page Builder
2. **Loading State**: Shows "OpenAI GPT-4 is analyzing..."
3. **API Call**: Sends content to `/api/ai/analyze`
4. **AI Processing**: GPT-4o-mini analyzes your sales copy
5. **Smart Results**: Specific, actionable feedback
6. **Fallback**: Local analysis if API fails
---
## 💰 **Cost Estimates**
### **Typical Analysis Costs**
- **Short Page** (5-10 blocks): ~$0.001-0.003
- **Medium Page** (15-25 blocks): ~$0.003-0.008
- **Long Page** (30+ blocks): ~$0.008-0.015
### **Monthly Estimates** (100 analyses)
- **Light Usage**: ~$0.50-1.00
- **Regular Usage**: ~$1.00-3.00
- **Heavy Usage**: ~$3.00-8.00
### **Cost Optimization Tips**
- Use AI analysis for final review, not every edit
- GPT-4o-mini is 20x cheaper than GPT-4
- Usage tracking helps monitor costs
- Fallback ensures it works without API
---
## 🛠️ **Troubleshooting**
### **Common Issues**
#### **"OpenAI API key not configured"**
- Check your `.env.local` file exists
- Verify `OPENAI_API_KEY=sk-...` (no quotes)
- Restart your dev server
#### **"Invalid OpenAI API key"**
- Verify your API key is correct
- Check if it starts with `sk-`
- Ensure your OpenAI account has credits
#### **"OpenAI API quota exceeded"**
- Check your OpenAI billing dashboard
- Add payment method or increase limits
- The system will fallback to local analysis
#### **Analysis takes too long**
- GPT-4o-mini usually responds in 2-5 seconds
- Check your internet connection
- Verify OpenAI API status
---
## 📊 **Usage Monitoring**
Check your browser console for usage logs:
```
AI Analysis Usage: {
model: 'gpt-4o-mini',
timestamp: '2024-01-15T10:30:00.000Z',
responseTime: '3200ms',
promptTokens: 450,
completionTokens: 280,
totalTokens: 730,
estimatedCost: '$0.000109'
}
```
---
## 🎯 **Next Steps**
1. **Set up your API key** (most important!)
2. **Test with sample content** to see AI in action
3. **Monitor costs** in your OpenAI dashboard
4. **Enjoy AI-powered sales optimization!** 🚀
---
## 🔒 **Security Notes**
- ✅ **API key is server-side only** (not exposed to browser)
- ✅ **Environment file is gitignored** (won't be committed)
- ✅ **Error handling** prevents crashes
- ✅ **Fallback system** ensures reliability
Your content is sent to OpenAI for analysis - review their privacy policy if you have concerns about sensitive content.
---
**🎉 Enjoy your AI-powered sales page builder!**
> 屬於 [research/](./README.md)。涵蓋 LLM-as-Judge、Reasoning Model、評估維度、Judge 設計原則。
> ⚠️ Note (Option A): `hwp-web (planned)` is intentionally excluded/disabled in this repo snapshot.
Here are three new, highly specialized AI agents for the T20 framework:
The **LLM Judge** is LLMTrace's third security detector alongside the