Secrets and .env hygiene
Notebook· 00.04· 60–75 min· Lesson 5 of 129
The notebook opens in your lab, in a new tab. If your server is stopped, it starts first (a few seconds).
By the end you can
- Create a Groq API key and store it in a
.envfile that git ignores. - Load
.envwithpython-dotenvand explain how the file is found and which value wins (override). - Check that keys exist without ever printing them, using
mastery.config. - Name the environment variables that LangChain, LangSmith, and Groq read.
- Respond correctly to a leaked key (rotate first, clean up second).
Before you start
Lessons 00.01–00.03, the lc-mastery environment, a free Groq account.
Python in this lesson
Python guideNew hereSlicing (x[1:3])any() and all()Set comprehensionsSpreading into a list ([*a, *b])asserttempfiledotenvgetpass
