@ai-sdk/google 3.0.120 → 3.0.122

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.
@@ -1082,6 +1082,7 @@ The following Zod features are known to not work with Google Generative AI:
1082
1082
 
1083
1083
  | Model | Image Input | Object Generation | Tool Usage | Tool Streaming | Google Search | URL Context |
1084
1084
  | ------------------------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- | ------------------- |
1085
+ | `gemini-3.8-flash` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
1085
1086
  | `gemini-3.7-flash` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
1086
1087
  | `gemini-3.6-flash` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
1087
1088
  | `gemini-3.5-flash` | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> | <Check size={18} /> |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google",
3
- "version": "3.0.120",
3
+ "version": "3.0.122",
4
4
  "license": "Apache-2.0",
5
5
  "sideEffects": false,
6
6
  "main": "./dist/index.js",
@@ -36,8 +36,8 @@
36
36
  }
37
37
  },
38
38
  "dependencies": {
39
- "@ai-sdk/provider": "3.0.15",
40
- "@ai-sdk/provider-utils": "4.0.50"
39
+ "@ai-sdk/provider": "3.0.16",
40
+ "@ai-sdk/provider-utils": "4.0.51"
41
41
  },
42
42
  "devDependencies": {
43
43
  "@types/node": "20.17.24",
@@ -159,7 +159,9 @@ export class GoogleGenerativeAIImageModel implements ImageModelV3 {
159
159
  };
160
160
 
161
161
  const { responseHeaders, value: response } = await postJsonToApi<{
162
- predictions: Array<{ bytesBase64Encoded: string }>;
162
+ predictions: Array<
163
+ { bytesBase64Encoded: string } | { raiFilteredReason: string }
164
+ >;
163
165
  }>({
164
166
  url: `${this.config.baseURL}/models/${this.modelId}:predict`,
165
167
  headers: combineHeaders(await resolve(this.config.headers), headers),
@@ -171,14 +173,22 @@ export class GoogleGenerativeAIImageModel implements ImageModelV3 {
171
173
  abortSignal,
172
174
  fetch: this.config.fetch,
173
175
  });
176
+ const imagePredictions = response.predictions.filter(
177
+ (prediction): prediction is { bytesBase64Encoded: string } =>
178
+ 'bytesBase64Encoded' in prediction,
179
+ );
180
+
174
181
  return {
175
- images: response.predictions.map(
176
- (p: { bytesBase64Encoded: string }) => p.bytesBase64Encoded,
182
+ images: imagePredictions.map(
183
+ ({ bytesBase64Encoded }) => bytesBase64Encoded,
177
184
  ),
185
+ ...(response.predictions.some(
186
+ prediction => 'raiFilteredReason' in prediction,
187
+ ) && { isRetryable: false }),
178
188
  warnings,
179
189
  providerMetadata: {
180
190
  google: {
181
- images: response.predictions.map(() => ({
191
+ images: imagePredictions.map(() => ({
182
192
  // Add any prediction-specific metadata here
183
193
  })),
184
194
  },
@@ -341,6 +351,9 @@ export class GoogleGenerativeAIImageModel implements ImageModelV3 {
341
351
 
342
352
  return {
343
353
  images,
354
+ ...(result.finishReason.unified === 'content-filter'
355
+ ? { isRetryable: false }
356
+ : {}),
344
357
  warnings,
345
358
  providerMetadata: {
346
359
  google: {
@@ -375,7 +388,12 @@ const googleImageResponseSchema = lazySchema(() =>
375
388
  zodSchema(
376
389
  z.object({
377
390
  predictions: z
378
- .array(z.object({ bytesBase64Encoded: z.string() }))
391
+ .array(
392
+ z.union([
393
+ z.object({ bytesBase64Encoded: z.string() }),
394
+ z.object({ raiFilteredReason: z.string() }),
395
+ ]),
396
+ )
379
397
  .default([]),
380
398
  }),
381
399
  ),
@@ -34,6 +34,7 @@ export type GoogleGenerativeAIModelId =
34
34
  | 'gemini-3.5-flash-lite'
35
35
  | 'gemini-3.6-flash'
36
36
  | 'gemini-3.7-flash'
37
+ | 'gemini-3.8-flash'
37
38
  // latest version
38
39
  // https://ai.google.dev/gemini-api/docs/models#latest
39
40
  | 'gemini-pro-latest'
@@ -36,6 +36,7 @@ export type GoogleInteractionsModelId =
36
36
  | 'gemini-3.5-flash-lite'
37
37
  | 'gemini-3.6-flash'
38
38
  | 'gemini-3.7-flash'
39
+ | 'gemini-3.8-flash'
39
40
  | 'lyria-3-clip-preview'
40
41
  | 'lyria-3-pro-preview'
41
42
  | (string & {});