Inject structured output into prompts for unsupported models
Calvin Cheng
When using AI SDK from Vercel, when providing a zod schema when doing object generation it will always output the expected structure regardless if the model supports it or not.
I assume they detect if the model natively supports structured output and uses that, otherwise just injects the schema into the prompt.
Right now, if someone working on prompts has everything working well with structured outputs, but we has to use another model, they would have to copy and paste that into the prompt manually.
Maybe a good way to do this is to define a default template for how the json schema will be injected and make that customizable as well.
Jonathan Pedoeem
That is an interesting idea -- we have a philosophy of not changing the actual customer prompt, although maybe adding some form of additional features around this should be good.
Ill take this back to the team.