'Secrets' object is not callable

st.secrets acts like a dictionary, so the syntax should be:

openai.api_key = st.secrets["API_KEY"]

Assuming you defined API_KEY in the secrets.toml. Check Secrets management - Streamlit Docs for details and examples.

1 Like