Building with LLMs: APIs, prompts and structured output

Treat the model as an unreliable component you can engineer around: robust API calls, prompts you can test, outputs you can parse, tools it can call.

This is the applied core. You will call hosted and local models robustly, write prompts as testable artefacts, force machine-readable output, give the model tools, and manage context and cost. Every pattern here reappears inside agents and RAG.

By the end: You can build a reliable single-call LLM feature: validated structured output, retries, streaming, tool use, cost tracking, and a prompt you can regression-test.

6 topics · about 25 hours

Stage progress0 / 6

Do these first

LLM internals

Resist the urge to reach for a framework in this stage. The SDK plus Pydantic is enough, and writing the loops yourself is what makes the later frameworks legible.

  1. 01

    Calling LLM APIs robustly

    4 h

  2. 02

    Prompt engineering as an engineering discipline

    5 h

  3. 03

    Structured outputs and validation

    4 h

  4. 04

    Function calling: giving the model tools

    4 h

  5. 05

    Context windows, caching and cost control

    4 h

  6. 06

    Running open models locally with Hugging Face

    4 h

Build this to prove it

A typed extraction service

Build an API that turns messy documents (invoices, emails or support tickets) into validated JSON. Use structured output with a validation-and-retry loop, cache the long instructions, stream where it helps, and log tokens and cost per request.

  • FastAPI service with a Pydantic response model and input limits
  • Retry loop that feeds validation errors back to the model
  • Prompt caching on the static instructions, with measured savings
  • A golden set of 30 documents and a script that reports accuracy per field