To use your environment variables in a secure way you need to do this:
-
Go to
https://huggingface.co/spaces/USER/SPACE_ID/settings
-
Create Private Secret. Let’s say you name it “YOUR SECRET KEY”
-
Go to your app.py script and add these lines:
import os
api_key = os.getenv("YOUR SECRET KEY")
client = OpenAI(api_key=api_key)