structuredOutput with HTTP API

How do you use structuredOutput via the HTTP API? I see that there is a structuredOutput.schema property that can be passed in the POST body, but I'm not sure what format it's meant to be in. When passing json schema I seem to get errors.
3 Replies
Mastra Triager
Mastra Triager2mo ago
GitHub
[DISCORD:1433953229430980729] structuredOutput with HTTP API · Iss...
This issue was created from Discord post: https://discord.com/channels/1309558646228779139/1433953229430980729 How do you use structuredOutput via the HTTP API? I see that there is a structuredOutp...
Abhi Aiyer
Abhi Aiyer6d ago
Hey @switchtrue we'll take a look! @switchtrue give me a example of the json schema you passed, cause we do support this
Daniel Lew
Daniel Lew6d ago
@switchtrue I'm taking a look at this now, and I can use structuredOutput with both json schema and zod with no issues. It's possible that there's a conversion issue, so I opened this PR to use the same conversion methods we use in other parts of our codebase to get rid of possible edge cases https://github.com/mastra-ai/mastra/pull/10730
GitHub
fix(client-js): use schema-compat zodToJsonSchema for consistent Zo...
The client-js package had its own simpler zodToJsonSchema implementation that was missing critical features from schema-compat. This could cause issues when users pass Zod schemas with z.record() o...

Did you find this page helpful?