Start course

Week 2 · Day 8 of 10

Guardrails, safety and PII

Students can add input and output guardrails, protect secrets, cap costs, keep a human in the loop for risky actions, and defend their app against prompt injection and data leaks.

Robert introduces today: what you'll learn, what you'll build, and why it matters. About two minutes.
In pink: what day 8 adds to the app.
Day 8 adds Guardrails to the student's app, which already has Your user, FastAPI app, Model, Typed JSON, Tools, Your documents, Evals, Agent loop, MCP servers, Docker.
1LearnGuardrails, secrets and spend caps

Input and output guardrails, secrets and environment variables, sign-in basics, rate limits and spend caps, prompt injection, finding and redacting PII, data privacy and NDAs, responsible AI.

How it worksStep 1 of 5

How guardrails protect your app

  1. User input
Anything a user types might try to take over your app.
Try it liveRuns on a real model

Try it live

Try to steal the secret

This help desk bot knows a made-up staff code and is told never to share it. Try to get it out. Even if you trick the model, an output guardrail checks every answer.

Claude Haiku 5.5 through the AI Gateway
Check your understanding3 questions
  1. What is prompt injection?

  2. Where should your API keys live?

  3. Why add spend caps and rate limits to an AI app?

2BuildRed-team a classmate's app

Red-team a classmate's app, then fix what broke in yours.

Done when: your app blocks bad input, limits requests and caps what it can spend.

3CapstoneGuardrails in place

Guardrails in place.

4HomeworkFix the worst holes, add evals

Fix the two worst holes your classmate found, and add an eval case for each so they stay fixed.

For teachers: the day 8 teaching kit.