Structured Responses
62%
Lesson 5 of 8

Structured Responses

Applications are easier to build when the model returns predictable fields your UI can render directly.

Active reading
Why this matters

Applications are easier to build when the model returns predictable fields your UI can render directly.

Schema

Define response fields.

Parse

Convert the model output into application data.

Validate

Reject malformed or unsafe values.

Understand the working model

Instead of asking for a paragraph and scraping it, request structured data. Your server can validate the response before the UI displays it or stores it.

Keep schemas small. If your UI only needs title, summary and three actions, do not ask for twenty fields. Simpler contracts are easier to validate and maintain.

Example
Response: {"title":"...","summary":"...","actions":["...","...","..."]}. Server validates all fields before returning JSON to the browser.
Practice

Apply the pattern above to one real task you already do. Keep the first version small enough that you can inspect every input and output.

Common mistake

Do not render untrusted model HTML directly into the page.

Key takeaway

Use a small response schema, validate it on the server, then render safe fields in the UI.

Next lesson

Loading and Errors

Continue to the next lesson.

Continue →