Skip to content

Support for zod/v4-mini #1564

Open
Open
@MarkLee425

Description

@MarkLee425

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions