How to manage user secrets and API Keys?

As per the above page I didn’t see the Space repository to add a new variable or secret.
new variable or secret are deprecated in settings page. How to handle the API Keys and user secrets like Secrets Manager?

hi @KushwanthK , You can access secrets and variables on your Space Settings page

I replied to this question here:

Would be nice if the huggingface’s team adds this little detail to the docs: Spaces Overview

To use your environment variables in a secure way you need to do this:

  1. Go to

  2. Create Private Secret. Let’s say you name it “YOUR SECRET KEY”

  3. Go to your script and add these lines:

import os

api_key = os.getenv("YOUR SECRET KEY")
client = OpenAI(api_key=api_key)