A depleted API key exported in the shell silently shadows the working key in .env
python-dotenv load_dotenv() does not override variables already in the environment (override=False by default). If the shell profile exports an old GEMINI_API_KEY / model ID, every script and pytest run from that shell uses it, even though .env holds a working key. Symptom: Gemini returned 402 RESOURCE_EXHAUSTED (prepayment credits are depleted) locally while teammates traced successful calls with the .env key. Check with: env | grep GEMINI. Prove the .env key on its own with: env -u GEMINI_API_KEY -u GEMINI_FAST_MODEL bash -c "set -a; source .env; set +a; <cmd>". Fix: unset or remove the shell export, or call load_dotenv(override=True). Separate pitfall when masking secrets with sed s/URL=.*/URL=<set>/: it also prints <set> for an empty value. Check ${#VAR} for the real length.