-
Copy the example environment file:
cp .env.example .env
-
Edit
.envand add your OpenAI API key:nano .env # or open .env -
Add your API key:
OPENAI_API_KEY=sk-proj-your-actual-key-here -
Save and close the file
- Go to https://platform.openai.com/api-keys
- Sign in or create an account
- Click "Create new secret key"
- Copy the key (starts with
sk-proj-...) - Paste it into
.env
- ✅
.envis in.gitignore- your key will NOT be committed to git - ✅ Never share your
.envfile or commit it to version control - ✅ Use
.env.exampleto show the structure without exposing secrets
Run the test script to verify everything works:
python3 test_intelligent_cleaning.pyIf you see an error about the API key, double-check:
- The file is named exactly
.env(not.env.txtor anything else) - The key is on a line like:
OPENAI_API_KEY=sk-proj-... - There are no extra spaces around the
=sign - The key is valid and not expired
The intelligent content analysis uses GPT-4o-mini, which is very cost-effective:
- Per document: ~$0.0003 (0.03 cents)
- 1,000 documents: ~$0.30
- 10,000 documents: ~$3.00
You can override default settings in .env:
# Change the LLM model (default: gpt-4o-mini)
LLM_MODEL=gpt-4o-mini
# Adjust temperature for more/less randomness (default: 0.1)
LLM_TEMPERATURE=0.1
# Maximum tokens for LLM response (default: 1500)
LLM_MAX_TOKENS=1500
# Rate limit requests per minute (default: 500)
LLM_RATE_LIMIT_RPM=500
- Make sure
.envexists in the same directory as the scripts - Check that
OPENAI_API_KEY=has your actual key after the= - Try printing the env var:
python3 -c "import os; print(os.getenv('OPENAI_API_KEY'))"
- Your key may be expired or invalid
- Generate a new key at https://platform.openai.com/api-keys
- Make sure you copied the entire key (they're long!)
- You're making requests too quickly
- Wait a minute and try again
- Or reduce
LLM_RATE_LIMIT_RPMin.env