Spring AI supports native structured output, which sends JSON schema constraints directly to the model API rather than embedding formatting instructions in the prompt. This guarantees schema-conformant JSON responses every time, unlike the previous approach that relied on prompt instructions and was non-deterministic. The tutorial walks through building a REST endpoint that returns typed book data, demonstrates how to log outgoing requests using the SimpleLoggerAdvisor to inspect the schema being sent, and shows how to enable native structured output with a single configuration flag. Currently supported by OpenAI GPT-4o and later models, as well as Anthropic Claude.

17m watch time

Sort: