Self-Correcting Structured Output In Spring AI 2.0 Daniil Medvedev [CpuCY55pXjS]

Tag: #Daniil Medvedev, #jake laravia, #jasmine paolini, #dybala

Everyone's fix for unreliable LLM JSON is the same: write a stricter prompt and beg the model. That's not engineering, that's hoping. Spring AI 2.0 changes that.

In this video, I will walk you through the new self-correcting structured output feature in Spring AI 2.0. You'll learn how to validate model responses against your schema and automatically hand errors back to the model for a retry, all with a single line of code that's off by default so nothing breaks.

- Understand how structured output turns messy LLM text into typed Java objects

- See a real failure mode using a small open-source model with Ollama

- Add automatic schema validation and self-correcting retries with one line of code

- Learn the difference between prompt-level and native (API-level) structured output

- Know why validation is off by default and how to safely enable it

0:00 - Intro: Stop hoping for valid JSON

0:45 - What we're building today

1:15 - The blog post & how structured output works

3:00 - scavengers reign Reference docs & creating the anversa project

4:30 - Setting up the API key and chat model

6:00 - Building the TalkSubmission record & controller

8:30 - Demo 1: Typed response with Anthropic

11:00 - Switching to Ollama to trigger a failure

13:00 - Demo 2: Adding schema validation & self-correction

15:30 - Inspecting the generated JSON schema

17:00 - Native structured output at the API level

19:00 - Recap & what's next in Spring AI 2.0

#SpringAI #Java #SpringBoot #LLM #AI #StructuredOutput #Anthropic #Ollama

Resources & Links mentioned in this video:

GitHub Repo:

Blog Post: Self-Correcting Structured wnba scores Output in Spring AI 2.0:

Spring Initializr:

Ollama:

Connect with me:

Website:

Twitter:

Github:

LinkedIn:

Newsletter:

SUBSCRIBE TO MY CHANNEL: