Repository: vercel/ai (TypeScript)

Issue:
V5 - Tool execute() won't infer zod schema parameters
### Description

Setting up zod.object as the tool parameters result in error in the execute function.

![Image](https://github.com/user-attachments/assets/34b6af65-14fd-4e2c-878f-1d5009fd9b4e)

![Image](https://github.com/user-attachments/assets/55d35a24-8880-489b-a628-3c626d68ea58)

also at runtime, Im getting this error back from openAI 

```
"data":{"error":{"message":"Invalid schema for function 'getAvailableTimeSlots': schema must be a JSON Schema of 'type: \"object\"', got 'type: \"None\"'.","type":"invalid_request_error","param":"tools[0].parameters","code":"invalid_function_parameters"}}}}}
```

EDIT: figured out that in V5 the **parameters** property was replaced with **inputSchema** (is that correct?)

### AI SDK Version

- ai: 5.0.0.beta-2
- @ai-sdk/openai: 2.0.0-beta.2
- @ai-sdk/react: 2.0.0-beta.2


Discussion: Yes `parameters` is now `inputSchema`. Does it work for you now? You also need to have Zod 3.25 or newer
well it does not have the type error anymore, 
but im getting an error from openAI when trying to use the tool...

`{"error":{"message":"Invalid schema for function 'getAvailableTimeSlots': In context=(), 'required' is required to be supplied and to be an array including every key in properties. Missing 'specialist_id'.","type":"invalid_request_error","param":"tools[0].parameters","code":"invalid_function_parameters"}}`

This is partially my schema

```
tool({
    description:
      "Find available appointment times for specialist",
    inputSchema: z.object({
      preferred_datetime: z
        .string()
        .describe(
          "Customer's preferred appointment datetime in ISO 8601 format (e.g., '2024-03-20T14:30:00Z')"
        ),
      specialist_id: z
        .string()
        .optional()
        .describe("Specific technician ID to check. Leave empty to find any available technician.")
     })
})
```
@amitdadon can you replace `optional` with `nullable`?
Please try `@ai-sdk/openai@2.0.0-beta.3`



Fix (patch):
diff --git a/.changeset/spicy-bats-impress.md b/.changeset/spicy-bats-impress.md
new file mode 100644
index 000000000000..a797c4ca3874
--- /dev/null
+++ b/.changeset/spicy-bats-impress.md
@@ -0,0 +1,5 @@
+---
+'@ai-sdk/openai': major
+---
+
+fix (provider/openai): default strict mode to false
diff --git a/packages/openai/src/openai-chat-language-model.ts b/packages/openai/src/openai-chat-language-model.ts
index 7ea84a5a965c..5257e21f9782 100644
--- a/packages/openai/src/openai-chat-language-model.ts
+++ b/packages/openai/src/openai-chat-language-model.ts
@@ -117,6 +117,8 @@ export class OpenAIChatLanguageModel implements LanguageModelV2 {
 
     warnings.push(...messageWarnings);
 
+    const strictJsonSchema = openaiOptions.strictJsonSchema ?? false;
+
     const baseArgs = {
       // model id:
       model: this.modelId,
@@ -147,13 +149,12 @@ export class OpenAIChatLanguageModel implements LanguageModelV2 {
       presence_penalty: presencePenalty,
       response_format:
         responseFormat?.type === 'json'
-          ? // TODO convert into provider option
-            structuredOutputs && responseFormat.schema != null
+          ? structuredOutputs && responseFormat.schema != null
             ? {
                 type: 'json_schema',
                 json_schema: {
                   schema: responseFormat.schema,
-                  strict: true,
+                  strict: strictJsonSchema,
                   name: responseFormat.name ?? 'response',
                   description: responseFormat.description,
                 },
@@ -276,6 +277,7 @@ export class OpenAIChatLanguageModel implements LanguageModelV2 {
       tools,
       toolChoice,
       structuredOutputs,
+      strictJsonSchema,
     });
 
     return {
diff --git a/packages/openai/src/openai-chat-options.ts b/packages/openai/src/openai-chat-options.ts
index 7d170d55f1ce..ca72a130df69 100644
--- a/packages/openai/src/openai-chat-options.ts
+++ b/packages/openai/src/openai-chat-options.ts
@@ -118,6 +118,13 @@ export const openaiProviderOptions = z.object({
    * @default 'auto'
    */
   serviceTier: z.enum(['auto', 'flex']).optional(),
+
+  /**
+   * Whether to use strict JSON schema validation.
+   *
+   * @default true
+   */
+  strictJsonSchema: z.boolean().optional(),
 });
 
 export type OpenAIProviderOptions = z.infer<typeof openaiProviderOptions>;
diff --git a/packages/openai/src/openai-prepare-tools.ts b/packages/openai/src/openai-prepare-tools.ts
index 7dcc5ddc42aa..3e4441b61876 100644
--- a/packages/openai/src/openai-prepare-tools.ts
+++ b/packages/openai/src/openai-prepare-tools.ts
@@ -11,10 +11,12 @@ export function prepareTools({
   tools,
   toolChoice,
   structuredOutputs,
+  strictJsonSchema,
 }: {
   tools: LanguageModelV2CallOptions['tools'];
   toolChoice?: LanguageModelV2CallOptions['toolChoice'];
   structuredOutputs: boolean;
+  strictJsonSchema: boolean;
 }): {
   tools?: OpenAITools;
   toolChoice?: OpenAIToolChoice;
@@ -40,7 +42,7 @@ export function prepareTools({
             name: tool.name,
             description: tool.description,
             parameters: tool.inputSchema,
-            strict: structuredOutputs ? true : undefined,
+            strict: structuredOutputs ? strictJsonSchema : undefined,
           },
         });
         break;
diff --git a/packages/openai/src/responses/openai-responses-language-model.ts b/packages/openai/src/responses/openai-responses-language-model.ts
index 96b19eb910f2..6c646dda7c47 100644
--- a/packages/openai/src/responses/openai-responses-language-model.ts
+++ b/packages/openai/src/responses/openai-responses-language-model.ts
@@ -101,7 +101,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV2 {
       schema: openaiResponsesProviderOptionsSchema,
     });
 
-    const isStrict = openaiOptions?.strictSchemas ?? true;
+    const strictJsonSchema = openaiOptions?.strictJsonSchema ?? false;
 
     const baseArgs = {
       model: this.modelId,
@@ -116,7 +116,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV2 {
             responseFormat.schema != null
               ? {
                   type: 'json_schema',
-                  strict: isStrict,
+                  strict: strictJsonSchema,
                   name: responseFormat.name ?? 'response',
                   description: responseFormat.description,
                   schema: responseFormat.schema,
@@ -195,7 +195,7 @@ export class OpenAIResponsesLanguageModel implements LanguageModelV2 {
     } = prepareResponsesTools({
       tools,
       toolChoice,
-      strict: isStrict,
+      strictJsonSchema,
     });
 
     return {
@@ -912,7 +912,7 @@ const openaiResponsesProviderOptionsSchema = z.object({
   store: z.boolean().nullish(),
   user: z.string().nullish(),
   reasoningEffort: z.string().nullish(),
-  strictSchemas: z.boolean().nullish(),
+  strictJsonSchema: z.boolean().nullish(),
   instructions: z.string().nullish(),
   reasoningSummary: z.string().nullish(),
   serviceTier: z.enum(['auto', 'flex']).nullish(),
diff --git a/packages/openai/src/responses/openai-responses-prepare-tools.ts b/packages/openai/src/responses/openai-responses-prepare-tools.ts
index 7054cf05b233..8806130d17a0 100644
--- a/packages/openai/src/responses/openai-responses-prepare-tools.ts
+++ b/packages/openai/src/responses/openai-responses-prepare-tools.ts
@@ -8,11 +8,11 @@ import { OpenAIResponsesTool } from './openai-responses-api-types';
 export function prepareResponsesTools({
   tools,
   toolChoice,
-  strict,
+  strictJsonSchema,
 }: {
   tools: LanguageModelV2CallOptions['tools'];
   toolChoice?: LanguageModelV2CallOptions['toolChoice'];
-  strict: boolean;
+  strictJsonSchema: boolean;
 }): {
   tools?: Array<OpenAIResponsesTool>;
   toolChoice?:
@@ -42,7 +42,7 @@ export function prepareResponsesTools({
           name: tool.name,
           description: tool.description,
           parameters: tool.inputSchema,
-          strict: strict ? true : undefined,
+          strict: strictJsonSchema,
         });
         break;
       case 'provider-defined':
diff --git a/packages/openai/src/responses/openai-responses-settings.ts b/packages/openai/src/responses/openai-responses-settings.ts
index 0d0fb8e4dbac..570ad213ac02 100644
--- a/packages/openai/src/responses/openai-responses-settings.ts
+++ b/packages/openai/src/responses/openai-responses-settings.ts
@@ -44,5 +44,3 @@ export type OpenAIResponsesModelId =
   | 'gpt-3.5-turbo-1106'
   | 'chatgpt-4o-latest'
   | (string & {});
-
-export interface OpenAIResponsesSettings {}