Struggling With Setting OpenAI API Using Streamlit Secrets

Hi @Leghair, this is how I did it.

In my code, I reference the API key like below.

Import OS
os.environ["OPENAI_API_KEY"] = st.secrets["OPENAI_API_KEY"]

Then when you deploy the app, add the OpenAI key in the Advanced Setting.
Make sure the key name “OPENAI_API_KEY” in the setting matches what you use in the code.