OpenAI Setup

OpenAI Setup

Use OpenAI's GPT models for AI-powered SEO suggestions.

Get API Key

  1. Go to OpenAI Platform
  2. Sign up or log in
  3. Navigate to API Keys
  4. Create new secret key
  5. Copy the key

Set Environment Variable

# Linux/macOS export OPENAI_API_KEY=your_key_here # Windows (PowerShell) $env:OPENAI_API_KEY = "your_key_here"

Permanent Setup

echo 'export OPENAI_API_KEY=your_key_here' >> ~/.bashrc source ~/.bashrc

Usage

CLI

# Auto-detected from env capyseo analyze ./dist --ai # Explicit provider capyseo analyze ./dist --ai --ai-provider openai # Specific model capyseo analyze ./dist --ai --ai-provider openai --ai-model gpt-4o

Config File

// capyseo.config.js export default { ai: { enabled: true, provider: 'openai', model: 'gpt-4o-mini', cacheDir: '.capyseo-cache', cacheTTL: 86400000, }, };

Programmatic

import { SEOAnalyzer } from '@capyseo/core'; const analyzer = new SEOAnalyzer({ aiProvider: 'openai', aiApiKey: process.env.OPENAI_API_KEY, aiModel: 'gpt-4o-mini', });

Available Models

Model Speed Quality Cost
gpt-4o-mini Fast Good Low
gpt-4o Medium Best Higher
gpt-4-turbo Slower Excellent Higher

Recommended: gpt-4o-mini for cost-effective analysis.

Features

All AI features work with OpenAI:

  • Meta description generation
  • Alt text generation
  • Title suggestions
  • Content analysis

CI/CD Integration

GitHub Actions

- name: SEO Analysis run: capyseo analyze ./dist --ai --ai-provider openai env: OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}

Pricing

Model Input Output
gpt-4o-mini $0.15/1M tokens $0.60/1M tokens
gpt-4o $2.50/1M tokens $10/1M tokens

SEO analysis typically uses 500-2000 tokens per page.

Troubleshooting

"Invalid API key"

"Rate limit exceeded"

  • Wait and retry
  • Enable caching
  • Use gpt-4o-mini instead of gpt-4o

"Insufficient quota"

Comparison with Gemini

Feature OpenAI Gemini
Free tier Limited Yes
Speed Medium Fast
Quality Excellent Good
Cost Higher Lower

For most users, Gemini is recommended for cost efficiency.