#703·agentic

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-schema both openai's vendored version and the official package with openai mode 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-schema IF 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