OpenAI API · sdk · fg-0145

zodTextFormat with Zod 4 fails: schema must be a JSON Schema of type object, got type string

If you see Invalid schema for response_format: schema must be a JSON Schema of 'type: "object"', got 'type: "string"', the cause and the fix for OpenAI API are below, last verified 2026-10-15.

Verified Oct 2026trust 50/100
Symptom
Invalid schema for response_format: schema must be a JSON Schema of 'type: "object"', got 'type: "string"'.The structured outputs example from the docs fails after installing the latest zod
Cause
Before 6.7.0 the SDK converted schemas with a library that only understood Zod 3, so Zod 4 objects turned into a wrong schema.
Fix
Upgrade openai to 6.7.0 or later, or pin zod to version 3.
Apply
npm install openai@^6.7.0
Affected
openai-node earlier than 6.7.0 with zod 4; fixed in 6.7.0, 2025-10-24
Sources

Last verified 2026-10-15 · Confirmed by 0 builders

Related traps

Have your agent know this before it fails

$ /plugin marketplace add getfootgun/footgun
$ /plugin install footgun@footgun