Skip to main content
OpenAI provides industry-leading language models including GPT-4o and GPT-4o-mini, which offer excellent code understanding and analysis capabilities.

Why OpenAI?

  • High quality - Industry-leading models with excellent code understanding
  • Reliable - Stable API with consistent performance
  • Fast - GPT-4o-mini provides quick analysis with good quality
  • Well-documented - Extensive documentation and community support
OpenAI is a paid service. You’ll need to add credits to your account to use their API.

Get an API key

1

Create an account

Visit platform.openai.com and sign up.
2

Add billing

Navigate to Billing and add payment information.
3

Create an API key

Go to API Keys and create a new key.
4

Copy your key

Your key will look like sk-proj-.... Keep it secure and never commit it to version control.

Setup

Set the environment variable in your shell:
export OPENAI_API_KEY="sk-proj-..."
To make it permanent, add it to your shell profile:
# Add this line to your shell profile
export OPENAI_API_KEY="sk-proj-..."

Option 2: .env file

Create a .env file in your project directory:
.env
OPENAI_API_KEY=sk-proj-...
Add .env to your .gitignore to prevent committing your API key.

Option 3: Configuration file

Create a vibrant.config.js file:
vibrant.config.js
module.exports = {
  provider: 'openai',
  // API key will be read from environment variable
};

Usage

Run Vibrant with OpenAI:
# Auto-detect provider (if OPENAI_API_KEY is set)
vibrant . --ai

# Explicitly specify OpenAI
vibrant . --ai --provider openai

Available models

Vibrant uses gpt-4o-mini by default for the best balance of cost and quality.
  • Context: 128k tokens
  • Cost: ~0.15per1Minputtokens, 0.15 per 1M input tokens, ~0.60 per 1M output tokens
  • Speed: Very fast
  • Quality: Excellent for code analysis
  • Best for: Daily development, CI/CD pipelines
  • Context: 128k tokens
  • Cost: ~2.50per1Minputtokens, 2.50 per 1M input tokens, ~10 per 1M output tokens
  • Speed: Fast
  • Quality: Industry-leading
  • Best for: Critical analysis, complex codebases
  • Context: 128k tokens
  • Cost: ~10per1Minputtokens, 10 per 1M input tokens, ~30 per 1M output tokens
  • Speed: Medium
  • Quality: Excellent reasoning
  • Best for: Complex architectural analysis

Change the model

Set the OPENAI_MODEL environment variable:
export OPENAI_MODEL="gpt-4o"
vibrant . --ai --provider openai
Or in your .env file:
.env
OPENAI_API_KEY=sk-proj-...
OPENAI_MODEL=gpt-4o

Pricing

Typical costs for analyzing a medium-sized project (100 files):
ModelInput CostOutput CostTypical Total
gpt-4o-mini~$0.002~$0.005~$0.01 per analysis
gpt-4o~$0.04~$0.08~$0.15 per analysis
gpt-4-turbo~$0.15~$0.25~$0.50 per analysis
Vibrant’s Smart Summarizer reduces token usage by 50-60%, cutting your API costs in half.

Example output

vibrant . --ai --provider openai
🔮 Vibrant Analysis
─────────────────────

📡 AI Analysis (openai:gpt-4o-mini)

📊 Token Optimization:
   Original: 45,000 tokens
   Summarized: 18,000 tokens
   Savings: 60.0%

✔ Analysis complete

📋 Summary:
The codebase shows good structure but has several security concerns.
API credentials are hardcoded in multiple files and error handling
could be more robust.

🔍 Key Findings:
  • Critical: API keys in src/api.ts and src/config.ts
  • 12 empty catch blocks across the codebase
  • Inconsistent error handling patterns

💡 Recommendations:
  • Immediately move all credentials to environment variables
  • Implement a centralized error handling strategy
  • Add logging to catch blocks for debugging
  • Consider using a secret management service

✕ 3 errors · ⚠ 8 warnings · 100 files · 8s

Troubleshooting

Error: API key not found

OpenAI API error: No API key provided
Solution: Set the OPENAI_API_KEY environment variable:
export OPENAI_API_KEY="sk-proj-..."

Error: Insufficient credits

OpenAI API error: You exceeded your current quota
Solution: Add credits to your OpenAI account at Billing.

Error: Rate limit exceeded

OpenAI API error: Rate limit reached
Solution: Vibrant automatically retries with exponential backoff. If the issue persists, wait a few minutes or upgrade your OpenAI tier for higher rate limits.

Best practices

1

Start with gpt-4o-mini

Use the default model for daily development. It provides excellent quality at low cost.
2

Use gpt-4o for critical analysis

When analyzing production code or complex issues, upgrade to gpt-4o for the best results.
3

Monitor your usage

Check your usage dashboard regularly to track costs.
4

Secure your API key

Never commit API keys to version control. Use environment variables or secret management.

CI/CD integration

For GitHub Actions:
.github/workflows/code-quality.yml
name: Code Quality

on: [push, pull_request]

jobs:
  analyze:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      
      - name: Setup Node
        uses: actions/setup-node@v4
        with:
          node-version: '20'
      
      - name: Run Vibrant
        run: npx vibrant-cli . --ai --provider openai
        env:
          OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
Add OPENAI_API_KEY as a secret in your repository settings.

Next steps

AI providers overview

Compare all available providers

Configuration

Customize Vibrant’s behavior

Build docs developers (and LLMs) love