import os import secrets from typing import Optional class Settings: def __init__(self): # Generate a secure API key if not provided self.api_key: str = os.getenv("API_KEY", secrets.token_urlsafe(32)) # Generate a separate admin key for sensitive operations self.admin_key: str = os.getenv("ADMIN_KEY", secrets.token_urlsafe(32)) self.ollama_host: str = os.getenv("OLLAMA_HOST", "127.0.0.1:11434") self.app_host: str = os.getenv("APP_HOST", "0.0.0.0") self.app_port: int = int(os.getenv("APP_PORT", "7860")) # Print both keys for easy access print("=" * 60) print("🔑 AUTHENTICATION KEYS") print("=" * 60) print(f"🔐 API Key (for regular usage): {self.api_key}") print(f"🔧 Admin Key (for key management): {self.admin_key}") print("=" * 60) print("🚨 SAVE BOTH KEYS SECURELY!") print("🔐 API Key: Use for all model operations") print("🔧 Admin Key: Use for key management and admin operations") print("=" * 60) settings = Settings()