Back to Agent FAQs
HELP CENTER · FAQAgent2 min read

Can I require a structured response?

A schema is useful when the answer will be consumed by software rather than read only as prose. Define the fields and types your application expects, then validate the returned data before using it.

Agent

Design the contract first

List the fields your next step needs and choose suitable types for them. Keep the schema focused on the result, not every detail that could possibly be mentioned. A narrow contract is easier for the model to satisfy and easier for your application to validate.

Include required fields when downstream code cannot continue without them. If a value may be absent, decide how that should be represented instead of relying on free-form wording. The schema guides the response format; your prompt still needs to explain the task and the meaning of each field.

Validate before acting

Treat structured output as data that still needs validation. Check that required values are present, types are correct, and values make sense for your use case. A response that parses successfully can still be incomplete or semantically wrong.

When a result fails validation, report which field needs correction and request a revised response with that context. Do not silently pass malformed data into a database, workflow, or external service. This separation between generation and validation makes structured answers safer to automate.

Back to Agent FAQs