Skip to course content
Free generative AI app course

Generative AI Application Development with Python

Module 02 Activity

Scenario

Before the first real call, set up so that a mistake costs nothing and a leaked key is survivable.

What you build

A reproducible setup with secrets in the environment, a spend ceiling enforced in code, and a test suite that runs with no key.

Steps

  1. Move every key to the environment. Confirm no key is in any object you log.
  2. Search your git history for anything resembling a key. If you find one, rotate it first, then worry about the history.
  3. Cost your feature at realistic volume, including a retry multiplier and a 10x growth case.
  4. Implement a spend ceiling checked before each call, with a user-facing message when it fires.
  5. Default the model to a fake so a misconfigured environment fails in tests.
  6. Clone the repo fresh into a new directory with no environment set and confirm the tests pass.

Evidence to hand in

Review checklist