Skip to main content

Overview

To get an Agent run’s answer as a JSON object matching your own schema instead of freeform Markdown, request structured output by passing a schema when you start the run.

Provide a schema

Pass output_schema (an OpenAI-style response_format object) to get output.structured, a JSON result shaped by your schema, in addition to the usual cited output.text report.
A completion for the request above looks like this:
The matching output.grounding looks like the following, one entry per groundable field, each citing back into output.sources by source_id:

Schema validity

Create validates output_schema’s wrapper shape, including type, and json_schema.name / schema / strict for type json_schema, before billing anything, and rejects a malformed one there. It does not validate the schema’s content. For strict: true, every object in the schema needs its own additionalProperties: false, including nested ones like the array item object above. Create accepts a schema missing it, but the run then fails with stop_reason: invalid_output.

Results

A run that produces no JSON output at all fails with stop_reason: invalid_output rather than returning something unparsable. Ungroundable fields come back null in output.structured. This is the same “don’t guess” contract Answer follows.

Next steps