Secrets

One way to use secrets like APIkey or passwords is using a .toml file but in my case the secret APIkey changes every 12 hours, so i want user to enter the APIkey manually. Is there a way user can input APIkey and that can be used in the code at backend in production.?

OpenAI_key = “your OpenAI key”
(in secrets.toml file but i want take this as user input every time a user comes to my app and use that key in my code)

st.secrets[“OpenAI_key”] == “your OpenAI key”

Sure there is:

OpenAI_key = st.text_input(label="OpenAI key", type="password")

thank you!
does this key gets saved without the need to submit in a form/container?

It works just like any other user input. Whether you need a form or a container depends on the specifics of your application.

then we would need a session state to persist otherwise after everyrun you will have to keep entering the token. Also, two submit button will not work in 1 form.

Yes, you might need to keep it in session_state.

Forms can have more than one submit button. Whether that will work for your application or not, I don’t know.