.agents/skills/xsai/references/structured-output.md
Use this reference for generateObject, streamObject, tool(), rawTool(), and schema guidance.
generateObject: unary structured output with validationstreamObject: incremental structured outputBoth rely on schema conversion through xsschema.
xsAI supports Standard Schema style libraries through xsschema, including:
Use these when the user wants typed structured output. Some schema vendors need an extra JSON Schema converter package in the project:
zod-to-json-schema@valibot/to-json-schemagenerateObjectUse generateObject when the user wants a validated final object.
Important options:
schemaschemaNameschemaDescriptionstrictoutput: 'array'streamObjectUse streamObject when the user wants incremental parsing.
Important result shapes:
partialObjectStreamelementStreamstreamObject is async because schema conversion happens before the text stream starts.
tool(): use with Standard Schema librariesrawTool(): use with raw JSON SchemaUse tool() when the user already has a schema library in the project.
Use rawTool() when the user already has JSON Schema or wants zero schema-library coupling.
generateObject over asking the model for free-form JSON.streamObject when the UI or workflow benefits from partial structured output.tool() unless the user explicitly needs raw JSON Schema.