Open
Description
Confirm this is a Node library issue and not an underlying OpenAI API issue
- This is an issue with the Node library
Describe the bug
Currently zodResponseFormat from 'openai/helpers/zod' do not support zod v4-mini.
To Reproduce
import { zodResponseFormat } from 'openai/helpers/zod';
import z from 'zod/v4-mini';
const stream = await new OpenAI().chat.completions.create({
model: 'xxx-model',
messages: [
{
role: 'user',
content: "Hi, generate an object with 'hello' as key and 'world' as value",
},
],
stream: true,
response_format: zodResponseFormat(z.object({ hello: z.literal("world")}), 'response'),
});
It will have error that shows zod typing is not correct. Since it is using ZodMiniType in zod/v4-mini, they are not compatible.
Code snippets
import { zodResponseFormat } from 'openai/helpers/zod';
import z from 'zod/v4-mini';
const stream = await new OpenAI().chat.completions.create({
model: 'xxx-model',
messages: [
{
role: 'user',
content: "Hi, generate an object with 'hello' as key and 'world' as value",
},
],
stream: true,
response_format: zodResponseFormat(z.object({ hello: z.literal("world")}), 'response'),
});
OS
macOS
Node version
Node v24.1.0
Library version
openai 5.7.0