The .streamlit directory keeps Streamlit configuration files such as secrets.toml alongside a project. A common use is storing an API key outside the application code, then reading it through st.secrets. section 9.2.6
Store and use an API key
Create .streamlit/secrets.toml with llm_api_key = "sk-proj-...". Run streamlit run main.py from the directory containing main.py so Streamlit can find .streamlit, then pass st.secrets['llm_api_key'] to the Game instance. section 9.2.6
Treat the directory differently across local development and deployment:
- During local Docker Compose use, mount .streamlit into the container instead of placing it in the image. section 12.3.5
- On Elastic Beanstalk, provide secrets.toml through .ebextensions because the deployed application cannot rely on direct filesystem access. section 12.3.5
Listing 9.3 Placing your LLM API key in .streamlit/secrets.toml
llm_api_key = "sk-proj-..." #1
Inspect the minimal secrets.toml listing to see the plain, non-nested API-key format. section 9.2.6
