Build my path

2ab3d41course(app-engineer):curriculum preview · demo

LLM Apps, Properly

Call a model like a careful engineer: typed inputs, structured outputs, timeouts, streaming and logs.

track
App Engineer
level
Working
length
5 modules · about 12 hours

Your progress dot moves to this branch

foundationsbuildautomatedeploylead

Prerequisites

  • Comfortable in TypeScript or Python
  • Has called a REST endpoint

2ab3011docs:outcomes and build

You will be able to

  • Wrap a model call in one typed function
  • Get structured output and validate it
  • Stream responses without breaking the UI
  • Log every request with an id

Hands-on build

A typed model client

One module your app imports, with retries, timeouts, validation and request logs.

2ab3022feat:5 modules

Modules.

  1. module 1

    One request, end to end

    Outcome: Send, receive, log, and read the token counts.

    Lessons: What is in a request · Tokens and why they matter · Reading the response

  2. module 2

    A typed wrapper

    Outcome: A function with typed input and output and a timeout.

    Lessons: Designing the function signature · Timeouts and cancellation · Request ids

  3. module 3

    Structured output

    Outcome: Model output that passes a schema or is rejected.

    Lessons: Schemas as contracts · Validation errors back to the model · When to give up

    free Tool calls need contracts covers this module interactively.

  4. module 4

    Streaming UI

    Outcome: Tokens render as they arrive and cancel cleanly.

    Lessons: Server-sent streams · Partial output states · Cancel and retry buttons

  5. module 5

    Prompts as code

    Outcome: Prompts in version control with a small test set.

    Lessons: Templates and variables · Changing a prompt safely · Your first five test cases

2ab3033docs:sample lesson

Sample lesson · Timeouts and cancellation

A model call can take two seconds or forty. Your user will not wait forty. Pick a budget per call and stop waiting when it runs out.

An AbortController lets you cancel the request when the budget runs out or when the user leaves the page, so you stop paying for an answer nobody will read.

callModel.ts ts
export async function callModel(input: Prompt, budgetMs = 8000) {  const ctrl = new AbortController();  const timer = setTimeout(() => ctrl.abort(), budgetMs);  try {    const res = await fetch(MODEL_URL, { method: "POST", body: JSON.stringify(input), signal: ctrl.signal });    if (!res.ok) throw new ModelError(res.status);    return parseOutput(await res.json()); // throws if the shape is wrong  } finally {    clearTimeout(timer);  }}

2ab3044test:assessment rubric

Ready to merge when

CriterionReady to mergeNot yet
TypesInput and output types are checked at runtime, not only at compile time.Output is used as an untyped string.
FailureTimeout, rate limit and bad output each have a tested path.Errors surface as a blank screen.
LogsEach request can be found by id with its prompt and token counts.No way to find what was sent.