@ai-sdk/google 4.0.84 → 4.0.85

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -135,10 +135,9 @@ The following optional provider options are available for Google models:
135
135
 
136
136
  Optional. Enable structured output. Default is true.
137
137
 
138
- This is useful when the JSON Schema contains elements that are
139
- not supported by the OpenAPI schema version that
140
- Google uses. You can use this to disable
141
- structured outputs if you need to.
138
+ You can disable structured outputs when a schema is not supported or exceeds
139
+ Google's schema complexity limits. The model will still be instructed to
140
+ return JSON, but the schema will not be sent to Google.
142
141
 
143
142
  See [Troubleshooting: Schema Limitations](#schema-limitations) for more details.
144
143
 
@@ -995,14 +994,21 @@ Example response excerpt:
995
994
 
996
995
  #### Schema Limitations
997
996
 
998
- The Google Generative AI API uses a subset of the OpenAPI 3.0 schema,
999
- which does not support features such as unions.
1000
- The errors that you get in this case look like this:
997
+ The Google Generative AI API supports a subset of JSON Schema. Google notes that
998
+ [very large or deeply nested schemas may be rejected](https://ai.google.dev/gemini-api/docs/structured-output#limitations).
999
+ When a schema exceeds Google's complexity limit, the API may return the following
1000
+ generic error:
1001
1001
 
1002
- `GenerateContentRequest.generation_config.response_schema.properties[occupation].type: must be specified`
1002
+ `Request contains an invalid argument.`
1003
+
1004
+ You can work around this by simplifying the schema sent to Google. For example,
1005
+ remove unnecessary constraints or reduce nesting while preserving the fields
1006
+ and types the model needs to generate. If you need stricter client-side
1007
+ validation than the schema sent to Google, use [`jsonSchema`](/docs/reference/ai-sdk-core/json-schema)
1008
+ with a custom validation function or validate the generated output separately.
1003
1009
 
1004
1010
  By default, structured outputs are enabled (and for tool calling they are required).
1005
- You can disable structured outputs for object generation as a workaround:
1011
+ You can also disable provider-enforced structured outputs for object generation:
1006
1012
 
1007
1013
  ```ts highlight="3,8"
1008
1014
  const { output } = await generateText({
@@ -1032,10 +1038,9 @@ const { output } = await generateText({
1032
1038
  });
1033
1039
  ```
1034
1040
 
1035
- The following Zod features are known to not work with Google:
1036
-
1037
- - `z.union`
1038
- - `z.record`
1041
+ When `structuredOutputs` is `false`, Google still receives the JSON response MIME type
1042
+ but not the schema. Describe the required schema in your prompt. AI SDK
1043
+ will still validate the response against the schema in `Output.object`.
1039
1044
 
1040
1045
  ### Model Capabilities
1041
1046
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google",
3
- "version": "4.0.84",
3
+ "version": "4.0.85",
4
4
  "type": "module",
5
5
  "license": "Apache-2.0",
6
6
  "sideEffects": false,
@@ -36,7 +36,7 @@
36
36
  },
37
37
  "dependencies": {
38
38
  "@ai-sdk/provider": "4.0.19",
39
- "@ai-sdk/provider-utils": "5.0.50"
39
+ "@ai-sdk/provider-utils": "5.0.51"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@ai-sdk/test-server": "2.0.2",
@@ -266,7 +266,7 @@ export function createGoogle(
266
266
  }),
267
267
  ...options.headers,
268
268
  },
269
- `ai-sdk/google/${VERSION}`,
269
+ `ai-sdk-google/${VERSION}`,
270
270
  );
271
271
 
272
272
  const getSupportedUrls = (