Programming foundations · L1 · 15 min
Secrets stay out of the file
Learn in five minutes
- A key in a source file will be copied.
- Pass secrets by the environment of the machine that runs the call.
- This lab's Python files do not need a key.
- Logs should not print the key.
- If a key leaks, rotate it at the provider. Confirm that provider's current steps.
The failure mode is not only theft. A key in a screenshot becomes part of a slide. Crop it or do not capture it.
Visual
A redacted log line
- Write a log line that shows the model id and the status.
- Replace the key with the word redacted.
- Check the line with a search for common key prefixes before you share it.
Quiz
Ecosystem
- Secret
- A value that grants access. It is not lesson content.
Sisters: Git, HTTP, JSON, unit tests.
A Python script can later call a local runner or a cloud API with the same JSON shape.
The same notebook becomes the capstone log.
Config
- Write the goal in one sentence.
- Name the input and the allowed output.
- Save the trace next to the result.
Troubleshooting
- The answer looks fluent and is wrong. Check whether a source passage actually contains the claim.
- The loop never stops. Set a step cap and stop when the tool result repeats.
Sources and go deeper
- OWASP Top 10 for Large Language Model Applications community last checked 2026-10
- NIST AI Risk Management Framework spec last checked 2026-10
- Large language model — Wikipedia wikipedia last checked 2026-10