Search notes:

Python library: python-dotenv

Define a few (environment-) variables in ~/.env:
OPENAI_API_KEY=0123456789abcdef…
Then read the file and instantiate the environment variables in a Python script:
if not load_dotenv():
   print('Could not open .env')
   quit()


import os
print(os.getenv('OPENAI_API_KEY'))

Index