Support OpenAI's structured outputs mode
Author: transitive-bullshitCreated Apr 1, 2025Updated Apr 1, 2025
Labelsenhancement
- currently only JSON mode is supported
- there are quite a few schema constraints when using structured outputs, and many of the AI functions in the stdlib use features like
.optional(),.default(), etc which are not supported zod-to-json-schemaboth openai's vendored version and the official package withopenaimode don't support structured outputs- see the ai sdk's notes on structured outputs. they explicitly make them opt-in and warn about schema compatibility
- this will involve changes to the underlying
zod-to-json-schemaIF the user is using structured outputs, so we'll need to expose a different version of the AI functions in this case
see #702 for a repro
Source: transitive-bullshit/agentic