Skip to content

Latest commit

 

History

History
75 lines (55 loc) · 1.71 KB

File metadata and controls

75 lines (55 loc) · 1.71 KB

Setting Up Your OpenAI API Key

Quick Setup

If you have your API key ready, you can add it in one of these ways:

Option 1: Create .env file (Recommended - Most Secure)

  1. Create a file named .env in the project root (same folder as requirements.txt)
  2. Add this line:
    OPENAI_API_KEY=your-actual-api-key-here
    
  3. The system will automatically load it when you run the app

Note: The .env file is already in .gitignore so it won't be committed to git.

Option 2: Set Environment Variable

Windows PowerShell:

$env:OPENAI_API_KEY="your-actual-api-key-here"
python web_app.py

Windows CMD:

set OPENAI_API_KEY=your-actual-api-key-here
python web_app.py

Linux/Mac:

export OPENAI_API_KEY="your-actual-api-key-here"
python web_app.py

Option 3: Add to Config File (Less Secure)

You can also add it directly to config/config.yaml (though this is less secure):

ai:
  enabled: true
  api_key: "your-actual-api-key-here"  # Not recommended for production

Getting Your API Key

If you don't have one yet:

  1. Go to https://platform.openai.com/api-keys
  2. Sign in or create an account
  3. Click "Create new secret key"
  4. Copy the key (it starts with sk-)

Verify It's Working

When you run python web_app.py, you should see:

✓ AI/LLM service initialized

If you see:

Warning: OPENAI_API_KEY not set. Falling back to pattern matching.

Then the API key isn't being found. Check:

  • The .env file exists and has the correct format
  • The environment variable is set (if using Option 2)
  • No typos in the key name

Security Note

Never commit your API key to git! The .env file is already in .gitignore for safety.