-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup_api_key.py
More file actions
30 lines (25 loc) · 943 Bytes
/
setup_api_key.py
File metadata and controls
30 lines (25 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
"""
Interactive script to set up OpenAI API key.
"""
import os
import sys
print("="*60)
print("LiabilityIQ - OpenAI API Key Setup")
print("="*60)
print("\nThis will help you set up your OpenAI API key.")
print("You can get your API key from: https://platform.openai.com/api-keys")
print("\n" + "-"*60)
api_key = input("\nEnter your OpenAI API key (or press Enter to skip): ").strip()
if not api_key:
print("\nSkipped. You can set it up later.")
print("The system will work without AI (using pattern matching).")
sys.exit(0)
# Create .env file
env_path = os.path.join(os.path.dirname(__file__), ".env")
with open(env_path, 'w') as f:
f.write(f"OPENAI_API_KEY={api_key}\n")
print(f"\n[SUCCESS] API key saved to .env file")
print(f" File: {env_path}")
print(f" Key preview: {api_key[:15]}...{api_key[-4:]}")
print("\nYou're all set! AI features are now enabled.")
print("\nNote: The .env file is gitignored for security.")