How would I hide my files?
I need to include my API key to use the inference API, but how do I do that without making my key publicly visible in my space’s files?I don’t want to make it private.
2021-12-22T13:27:05Z
You can addsecretsto have access to variables such as API keys in your SpaceIf your app requires secret keys or tokens, don’t hard-code them inside your app! Instead, go to theSettingspage of your Space repository and enter your secrets there. The secrets will be exposed to your app withStreamlit Secrets Managementif you use Streamlit, and as environment variables in other cases.
2021-12-22T13:42:02Z
Out of curiosity, are these “secrets” accessible at all by moderators/Hugging Face in plain text? Or are they at least hashed and protected?
2021-12-22T13:46:25Z
I cannot even see the values of my own secretsthese are hashed and protected as far as I know, but I’ll let@cbensimongive a final confirmation.
2021-12-22T14:32:50Z
so if I added a secret under “API_TOKEN” , I’d do something like:import os
os.environ.getattribute("API_TOKEN")
2021-12-22T14:58:01Z
Yes, that looks good! Oros.environ["API_TOKEN"]should work  as well. You can try it out with a dummy token first, print the value, and see it in the logs (click in “Running”)