promptdojo_

.env, os.getenv, and the leak recovery you'll do at least once — step 8 of 9

Build a config loader. Write load_config(env) that:

  • Reads ANTHROPIC_API_KEY from env. If missing or empty, raise RuntimeError("ANTHROPIC_API_KEY missing").
  • Reads MODEL with a default of "claude-sonnet-4-6".
  • Reads DEBUG with a default of "false", normalizes it to a real bool by lowercasing and comparing to "true".
  • Returns a dict with keys api_key, model, and debug.

Then call it on the provided env and print one line per key.

Expected output:

api_key=sk-ant-test
model=claude-sonnet-4-6
debug=True

full-screen editor opens — close anytime to keep reading.