You can add secrets to have access to variables such as API keys in your Space 

If your app requires secret keys or tokens, don’t hard-code them inside your app! Instead, go to the Settings page of your Space repository and enter your secrets there. The secrets will be exposed to your app with Streamlit Secrets Management 1 if you use Streamlit, and as environment variables in other cases.