Structured Output From Language Models

Stephen Gruppetta 18 Lessons 6h 38m Updated intermediate ai

In this course, you’ll turn free text into data your code can use, with a language model and a schema. You’ll follow a neighborhood vet clinic whose online booking form has one free-text box, and build a script that turns each owner’s note into an appointment record the clinic’s system can trust.

You’ll learn how to:

  • Write a prompt that keeps your instructions apart from the owner’s note, and test it on a whole set of real notes
  • Choose a model and its settings for the job, from real costs and results
  • Ask for JSON that matches a schema with each provider’s structured output
  • Add askForJson() to your model module, for OpenAI or Anthropic
  • Catch records that match the schema but aren’t true, and check every record with Zod
  • Retry a bad answer once with the error, and hand everything else to a person instead of guessing

You’ll finish with a project: the clinic’s intake, which books what it can, sends the rest to the front desk’s list with a reason, and prints what the run cost.

This course is for JavaScript developers who’ve called a language model from their own code with fetch(), async and await, and who know Node scripts and npm. You’ll need Node 26, a terminal, an editor, and a key for OpenAI or Anthropic. The exercises need no key at all.

What’s Included:

  • 18 Lessons
  • Video Subtitles and Full Transcripts
  • Translated Subtitles in 8 Languages
  • 2 Downloadable Resources
  • Interactive Quiz to Check Your Progress
  • 4 Hands-On Coding Exercises
  • Q&A With JavaScript Experts: Ask a Question
  • Certificate of Completion

Downloadable Resources:

Related Learning Paths:

About Stephen Gruppetta

Stephen obtained a PhD in physics and worked as a physicist in academia for over a decade before becoming a programming educator. He's constantly looking for simple ways to explain complex things.

» More about Stephen

Each tutorial at RealJS is created by a team of developers so that it meets our high quality standards. The team members who worked on this tutorial are:

← Browse All Courses