You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The `structuredOutputs` parameter has been replaced with the `strictJsonSchema` provider option. It is now disabled by default.
3054
+
In AI SDK 5, the default OpenAI provider instance uses the Responses API, while AI SDK 4 used the Chat Completions API. The Chat Completions API remains fully supported and you can use it with `openai.chat(...)`.
3055
3055
3056
3056
```tsx filename="AI SDK 4.0"
3057
3057
import { openai } from'@ai-sdk/openai';
3058
3058
3059
+
const defaultModel =openai('gpt-4.1-mini'); // Chat Completions API
3060
+
```
3061
+
3062
+
```tsx filename="AI SDK 5.0"
3063
+
import { openai } from'@ai-sdk/openai';
3064
+
3065
+
const defaultModel =openai('gpt-4.1-mini'); // Responses API
The Responses and Chat Completions APIs have different behavior and defaults.
3074
+
If you depend on the Chat Completions API, switch your model instance to
3075
+
`openai.chat(...)` and audit your configuration.
3076
+
</Note>
3077
+
3078
+
#### Strict Schemas (`strictSchemas`) with Responses API
3079
+
3080
+
In AI SDK 4.0, you could set the `strictSchemas` option on Responses models (which defaulted to `true`). This option has been renamed to `strictJsonSchema` in AI SDK 5.0 and now defaults to `false`.
model: openai('gpt-4.1-2024'), // uses Responses API
3107
+
schema: z.object({
3108
+
// ...
3109
+
}),
3071
3110
providerOptions: {
3072
3111
openai: {
3073
-
strictJsonSchema: true, //renamed and opt-in via provider options
3112
+
strictJsonSchema: true, //defaults to false, opt back in to the AI SDK 4 strict behaviour
3074
3113
} satisfiesOpenAIResponsesProviderOptions,
3075
3114
},
3076
3115
});
3077
3116
```
3078
3117
3118
+
If you call `openai.chat(...)` to use the Chat Completions API directly, you can type it with `OpenAIChatLanguageModelOptions`. AI SDK 5 adds the same `strictJsonSchema` option there as well.
3119
+
3120
+
#### Structured Outputs
3121
+
3122
+
The `structuredOutputs` option is now configured using provider options rather than as a setting on the model instance.
3123
+
3124
+
```tsx filename="AI SDK 4.0"
3125
+
import { z } from'zod';
3126
+
import { generateObject } from'ai';
3127
+
import { openai } from'@ai-sdk/openai';
3128
+
3129
+
const result =awaitgenerateObject({
3130
+
model: openai('gpt-4.1', { structuredOutputs: true }), // use Chat Completions API
0 commit comments