AI Engineering
Build LLM-backed product features end to end against a deterministic local mock: form well-formed chat requests, structure prompts and validated JSON outputs, stream and retry safely, ground answers in retrieved sources, call tools inside bounded agent loops, defend against prompt injection, and evaluate quality with reproducible checks instead of one-off demos. No API keys and no network calls are used anywhere in the course.
What you will be able to do
#- Construct and read chat-completion style requests and responses, and explain the role of every field using a local mock client.
- Control output variability deliberately with sampling parameters and describe when determinism is required.
- Budget context windows and estimate token usage and cost with clearly labeled approximations.
- Produce schema-validated structured output with parse, validate and retry handling instead of trusting raw text.
- Assemble streamed deltas into full responses and cancel generation with abort signals.
- Classify model API failures and apply bounded retries, timeouts and graceful degradation.
- Implement cosine similarity retrieval over mock embedding vectors and rank documents by hand.
- Build a retrieval-grounded answer pipeline that cites sources and abstains when the answer is not in them.
- Define tool schemas, validate model-requested arguments against allowlists, and run the tool loop safely.
- Wrap model-plus-tools loops in explicit budgets, approval gates and audit trails that separate agents from demos.
- Recognize prompt injection through retrieved data and tool results, and apply data-boundary defenses with honest residual risk.
- Author small evaluation sets with deterministic graders and explain why a passing demo is not an evaluation.
- Express and gate uncertainty with abstention thresholds and self-consistency checks on scripted outputs.
- Audit an AI feature for secret exposure, data-boundary and abuse risks, and state residual risk honestly.
- Define an SLO with an error budget and degrade through a fallback ladder instead of failing.
- Integrate caching, retrieval, structured output, tool policy and fallbacks into one reviewed, observable pipeline.
Prerequisites
#Lessons
#Anatomy of a model API call
beginner · 35 minutes · 4 exercises
Construct a well-formed chat-style request object and explain the purpose of every top-level field.
Prompt structure: roles, data boundaries and few-shots
beginner · 40 minutes · 4 exercises
Assemble a messages array that separates system instructions, few-shot examples and user data into distinct roles.
Sampling parameters and determinism
beginner · 35 minutes · 4 exercises
Trace cumulative sampling over a fixed candidate table and predict the selected token for any given random value.
Tokens, context windows and cost
beginner · 40 minutes · 4 exercises
Estimate token counts with a clearly labeled characters-per-token approximation and state when it is unsafe to trust.
Structured output: extract, validate, repair
intermediate · 45 minutes · 5 exercises
Extract a JSON object from a reply that contains prose or markdown fences without throwing on malformed input.
Streaming responses and cancellation
intermediate · 40 minutes · 5 exercises
Assemble streamed deltas into the complete reply and explain why chunks are fragments rather than standalone values.
Errors, retries, timeouts and graceful degradation
intermediate · 45 minutes · 5 exercises
Classify model API failures into retryable and non-retryable classes with a stated first response for each.
Embeddings and cosine similarity
intermediate · 45 minutes · 4 exercises
Compute cosine similarity between small vectors by hand and in code, with deterministic rounding.
Retrieval-grounded answers with citations and abstention
intermediate · 50 minutes · 5 exercises
Implement top-k retrieval over mock embedding vectors and predict the retrieved chunk ids and scores.
Tool calling: schemas, validation and the execution loop
intermediate · 50 minutes · 5 exercises
Execute model-requested tool calls through an allowlist registry with argument validation and structured errors.
Bounded agent workflows: budgets, approvals, audit
advanced · 55 minutes · 5 exercises
Implement an agent loop with an explicit step budget that returns structured outcomes for done and budget-exhausted runs.
Prompt injection and data boundaries
advanced · 55 minutes · 5 exercises
Classify injection attempts as instruction override, data exfiltration or tool abuse, and identify the carrier channel.
Evaluation against demos: graders, sets and regressions
advanced · 55 minutes · 5 exercises
Implement an eval runner that applies deterministic graders over a case set and reports counts, not just a rate.
Uncertainty, abstention and calibration
advanced · 45 minutes · 5 exercises
Implement majority-vote self-consistency over scripted samples with a deterministic tie rule and an agreement signal.
Caching and latency budgets
advanced · 45 minutes · 5 exercises
Implement a deterministic response cache with explicit keys and TTL expiry, and predict hit, expired and miss lookups.
Observability: structured logs and request metrics
advanced · 45 minutes · 4 exercises
Build a structured, redacted log entry per model request with identity, parameters, outcome class and token usage.
Model routing and cost tiers
advanced · 45 minutes · 4 exercises
Implement a tier-based routing table that maps task classes to mock models with a stated reason, and a safe default for unknown classes.
Security review: keys, data boundaries and abuse cases
advanced · 50 minutes · 4 exercises
Audit an AI feature for secret exposure, data-boundary and abuse risks using a fixed review checklist.
Reliability: SLOs, budgets and fallbacks
advanced · 50 minutes · 4 exercises
Define an SLO for an AI feature in terms of measurable indicators and compute its error budget in minutes.
Capstone: ship a reviewed, observable AI feature
advanced · 60 minutes · 4 exercises
Integrate request building, caching, retrieval, structured output, tool policy and fallbacks into one deterministic mock pipeline.
Study journeys
#Skip-ahead journeys never remove a requirement. The prerequisite graph always reports the full chain; a skip-ahead course only marks where an assessment may substitute for study.
Experienced engineer skip-ahead
Senior frontend engineer refreshing depth
Bypass React fundamentals by assessment and go straight to rendering depth, browser internals, debugging and AI features.
- React and UI Engineeringskip by assessment
- Next.js App Router Mastery
- Browser Internals
- Debugging and Code Review
- AI Engineeringyou are here
Advanced canonical resources
AI product engineer
Product engineer adding LLM features
Ship grounded, evaluated AI features on top of a real backend without leaking data or keys.
- JavaScript Foundationsskip by assessment
- AI Engineeringyou are here
- Backend, APIs and Databases
Next in this journey: Backend, APIs and Databases