File: no-object-generated-content-filter.md | Updated: 11/15/2025
Menu
v5 (Latest)
AI SDK 5.x
Model Context Protocol (MCP) Tools
Client-Side Function Calls Not Invoked
Server Actions in Client Components
useChat/useCompletion stream output contains 0:... instead of text
Tool Invocation Missing Result Error
Streaming Not Working When Deployed
Streaming Not Working When Proxied
Getting Timeouts When Deploying on Vercel
useChat Failed to Parse Stream
Server Action Plain Objects Error
Custom headers, body, and credentials not working with useChat
TypeScript performance issues with Zod and AI SDK 5
Repeated assistant messages in useChat
onFinish not called when stream is aborted
Tool calling with generateObject and streamObject
Abort breaks resumable streams
Streaming Status Shows But No Text Appears
Stale body values with useChat
Unsupported model version error
Object generation failed with OpenAI
Model is not assignable to type "LanguageModelV1"
TypeScript error "Cannot find namespace 'JSX'"
React error "Maximum update depth exceeded"
Jest: cannot find module '@ai-sdk/rsc'
Copy markdown
Object generation failed with OpenAI
========================================================================================================================================================
When using generateObject or streamObject with OpenAI's structured output generation, you may encounter a NoObjectGeneratedError with the finish reason content-filter. This error occurs when your Zod schema contains incompatible types that OpenAI's structured output feature cannot process.
// Problematic code - incompatible schema typesimport { generateObject } from 'ai';import { openai } from '@ai-sdk/openai';import { z } from 'zod';
const result = await generateObject({ model: openai('gpt-4o-2024-08-06'), schema: z.object({ name: z.string().nullish(), // ❌ .nullish() is not supported email: z.string().optional(), // ❌ .optional() is not supported age: z.number().nullable(), // ✅ .nullable() is supported }), prompt: 'Generate a user profile',});
// Error: NoObjectGeneratedError: No object generated.// Finish reason: content-filter
OpenAI's structured output generation uses JSON Schema under the hood and has specific requirements for schema compatibility. The Zod methods .nullish() and .optional() generate JSON Schema patterns that are incompatible with OpenAI's implementation, causing the model to reject the schema and return a content-filter finish reason.
Replace .nullish() and .optional() with .nullable() in your Zod schemas when using structured output generation with OpenAI models.
import { generateObject } from 'ai';import { openai } from '@ai-sdk/openai';import { z } from 'zod';
// Correct approach - use .nullable()const result = await generateObject({ model: openai('gpt-4o-2024-08-06'), schema: z.object({ name: z.string().nullable(), // ✅ Use .nullable() instead of .nullish() email: z.string().nullable(), // ✅ Use .nullable() instead of .optional() age: z.number().nullable(), }), prompt: 'Generate a user profile',});
console.log(result.object);// { name: "John Doe", email: "john@example.com", age: 30 }// or { name: null, email: null, age: 25 }
| Zod Type | Compatible | JSON Schema Behavior |
| --- | --- | --- |
| .nullable() | ✅ Yes | Allows null or the specified type |
| .optional() | ❌ No | Field can be omitted (not supported) |
| .nullish() | ❌ No | Allows null, undefined, or omitted (not supported) |
For more details on structured output generation, see Generating Structured Data
For OpenAI-specific structured output configuration, see OpenAI Provider - Structured Outputs
On this page
Object generation failed with OpenAI
Deploy and Scale AI Apps with Vercel.
Vercel delivers the infrastructure and developer experience you need to ship reliable AI-powered applications at scale.
Trusted by industry leaders: