Deployed My App to Hugging Face Spaces

I just deployed my app to Hugging Face Spaces, and I’m encountering an issue with internet connectivity. Here’s the snippet of code that’s throwing an error:

response = requests.get("https://api.openai.com/v1/models", timeout=5)

if response.status_code == 200:

st.success("Internet connectivity is working.")

else:

st.error(f"Internet not reachable: {response.status_code} - {response.reason}")

While testing this on the Hugging Face Space, I get the following error:

Internet not reachable: 401 - Unauthorized

This same code works perfectly fine locally on my machine, which makes me wonder if the free tier of Hugging Face Spaces blocks internet access or if there’s something else I’m missing.