-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Replace internal usage of zod v3 with zod 4 mini #6540
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Labels
enhancement
New feature or request
Comments
13 tasks
gr2m
added a commit
that referenced
this issue
Jun 1, 2025
## Background zod 4 has now been released: https://zod.dev/v4 We want to support both zod 3 and zod 4 schemas for validation. ## Summary - update `zod` to latest (`3.25.32` as of May 28) - Update implementations of `generateObject()`, `streamObject()`, `generateText()`, `experimental_useObject()` from `@ai-sdk/react`, and `streamUI()` from `@ai-sdk/rsc` to accept both zod v3 and zod v4 (mini) schemas ## Verification - [x] `generateObject()`: `examples/ai-core/src/generate-object/openai.ts` - [x] `streamObject()`: `examples/ai-core/src/stream-object/openai.ts` - [x] `generateText()`: `examples/ai-core/src/generate-text/openai-output-object.ts` - [x] `experimental_useObject()`: `examples/next-openai/app/use-obj/page.tsx` - [x] `streamUI()`: `examples/next-openai/app/stream-ui/actions.tsx`, update: [comment](#6421 (comment)) ## Tasks - [x] Tests have been added / updated (for bug fixes / features) - [x] Documentation has been added / updated (for bug fixes / features) All the docs use `import { z } from 'zod';` which is zod v3. Should we update it to `zod/v4` to align with the recommendation on https://zod.dev/? - [x] A _patch_ changeset for relevant packages has been added (for bug fixes / features - run `pnpm changeset` in the project root) - [x] Formatting issues have been fixed (run `pnpm prettier-fix` in the project root) ## Future Work - [x] When using a zod 4 schema in `examples/next-openai/app/api/use-object/schema.ts`, then `useObject({ api: '/api/use-object', schema: notificationSchema })` in `examples/next-openai/app/use-object/page.tsx` sets the type of `{ object }` to `any`, and I couldn't figure out why that is. For now, I explicitly used a zod 3 schema for `notificationSchema`. - [x] `packages/svelte/src/structured-object.svelte.ts` - [x] `packages/svelte/src/tests/structured-object-synchronization.svelte` - [x] Upgrade all internal uses of `zod` to z4 (~102 files), try using `z4-mini`. - moved to #6540 ## Related Issues #5682
Is this an SDK v5-only fix? |
Yes. PR welcome 🙂 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Description
Follow up to
AI SDK Version
No response
The text was updated successfully, but these errors were encountered: