Skip to main content
Give a session a JSON Schema and the agent returns its result as JSON that follows it. Your code can then read the result without parsing prose. Structured output is available on sessions started without an agent. Turns sent to an agent do not take a schema.

Send a schema

Add schema to the request body:

Read the output

When the session is completed, read it:
output follows your schema. outputSchema echoes the schema you sent. output is also in GET /v1/sessions/{id}/artifacts.

Tips

  • Describe the task in prompt and the result’s shape in schema. The schema does not replace instructions.
  • Mark the fields you always need as required.
  • Use description on properties to say what each field means, for example the currency format you want.
  • output is filled only when the session completes. A failed session has error instead.