Secrets management for student projects: never commit an API key again

The habits that keep keys out of repositories and demos: ignored environment files, committed example files, server-side keys only, rotation after a leak, and what to do in the first ten minutes if one gets out.

Taking questions during a session
Taking questions during a session

Every semester a student shows me a repository with an LLM API key in the first commit, and every semester someone's key is found and drained within hours. Secrets management is not advanced; it is a set of habits that take an afternoon to learn and never to unlearn. Here are the ones I insist on in every workshop.

The basic setup

  1. Keys live in a local environment file that is listed in the repository's ignore file before the first commit.
  2. An example file with the variable names and no values is committed, so teammates know what to set.
  3. Code reads keys from the environment and fails loudly at startup if one is missing.
  4. Deployment platforms hold the production keys in their secret stores; nothing is typed into a config file.

Keys never reach the browser

A front end that calls a model provider directly is publishing your key to everyone who opens developer tools. All model calls go through your own API, which holds the key and can rate-limit. This is one reason the FastAPI + Next.js architecture has two services.

Demos and screenshots

Keys appear in terminal screenshots, screen recordings and pasted logs more often than in code. Redact before you post. Use short-lived or restricted keys for demos where you can.

If a key leaks

  • Revoke it first, investigate second. Minutes matter.
  • Rotate every other key that was in the same file.
  • Remove it from history if it was committed, and assume it was already copied.
  • Check the provider's usage dashboard and set a spending limit while you are there.

Beyond keys

Database URLs, signing secrets, service account files and webhook tokens follow the same rules. So do datasets with personal data, which is where privacy by design begins. A project that handles secrets correctly is a small but real signal to anyone reviewing it that you have shipped before.

SecuritySecretsStudentsBest practices
Pranjul Rathour
Pranjul Rathour
GenAI Engineer · Kanpur, Uttar Pradesh, India

GenAI engineer and AI product builder with 2+ years shipping production-grade AI systems: RAG pipelines, fine-tuned LLMs, hybrid retrieval and multi-modal apps across vision, speech and OCR, architected end to end from ingestion to deployment. Leads engineering for SCULT INDIA's 14-member team, founded the 500+ member TechVerse Enclave community and has mentored 200+ students. Three hackathon first prizes: Changethon 2025 (IIT Roorkee), Product Genesis at Vividhotsava 2025 (CSJMU Kanpur) and BYTEBATTLE (MeetKats).

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges. Email pranjulrathour41@gmail.com.

Keep reading

More on Shipping AI

All Shipping AI posts →
Campus talks · hackathon judging · mentoring

Want this as a live session at your college?

Open to GenAI roles, hackathon judging, mentorship sessions and guest talks at colleges.

Pranjul Rathour, GenAI engineer in Kanpur