Skip to content
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

generateObject throws error with o3-mini when schema has an optional param #4681

Closed
benhylak opened this issue Feb 3, 2025 · 1 comment
Closed
Assignees
Labels
ai/provider bug Something isn't working

Comments

@benhylak
Copy link

benhylak commented Feb 3, 2025

Description

Any optional property in a schema causes the following error:

Error in streaming examples: Error [AI_APICallError]: Invalid schema for response_format 'response': In context=('properties', 'recipe'), 'required' is required to be supplied and to be an array including every key in properties. Missing 'steps'.

The same schema works fine with Flash/Claude/4o. We rely on optional properties pretty heavily.

Code example

const test = await generateObject({
  model: openai("o3-mini"),
  schema: z.object({
    recipe: z.object({
      name: z.string(),
      ingredients: z.array(z.string()),
      steps: z.array(z.string()).optional(),
    }),
  }),
  prompt: 'Generate a lasagna recipe.',
});

AI provider

@ai-sdk/openai 1.1.9

Additional context

No response

@benhylak benhylak added the bug Something isn't working label Feb 3, 2025
@lgrammel
Copy link
Collaborator

lgrammel commented Feb 5, 2025

Duplicates #4662

@lgrammel lgrammel closed this as completed Feb 5, 2025
@shaper shaper self-assigned this Feb 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai/provider bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants