Microsoft.Extensions.AI–Part VI–Structured Output

Microsoft.Extensions.AI–Part VI–Structured Output

Microsoft.Extensions.AI supports structured output to force LLMs to return responses in specific JSON formats instead of free-form text. Developers can use generic methods like GetResponseAsync() to automatically infer JSON schemas from C# classes, or manually define schemas using the ResponseFormat property in ChatOptions. This enables programmatic processing of LLM responses by ensuring consistent data structures.

Table of contents