@ai-sdk/google 4.0.0-beta.43 → 4.0.0-beta.45

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.
Files changed (28) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/README.md +4 -4
  3. package/dist/index.d.ts +33 -33
  4. package/dist/index.js +46 -55
  5. package/dist/index.js.map +1 -1
  6. package/dist/internal/index.d.ts +9 -9
  7. package/dist/internal/index.js +22 -25
  8. package/dist/internal/index.js.map +1 -1
  9. package/docs/{15-google-generative-ai.mdx → 15-google.mdx} +36 -36
  10. package/package.json +2 -2
  11. package/src/{convert-google-generative-ai-usage.ts → convert-google-usage.ts} +6 -6
  12. package/src/{convert-to-google-generative-ai-messages.ts → convert-to-google-messages.ts} +14 -14
  13. package/src/{google-generative-ai-embedding-model.ts → google-embedding-model.ts} +10 -16
  14. package/src/{google-generative-ai-embedding-options.ts → google-embedding-options.ts} +1 -1
  15. package/src/{google-generative-ai-files.ts → google-files.ts} +3 -3
  16. package/src/{google-generative-ai-image-model.ts → google-image-model.ts} +16 -20
  17. package/src/{google-generative-ai-image-settings.ts → google-image-settings.ts} +2 -2
  18. package/src/{google-generative-ai-language-model.ts → google-language-model.ts} +28 -34
  19. package/src/{google-generative-ai-options.ts → google-options.ts} +2 -2
  20. package/src/google-prepare-tools.ts +3 -3
  21. package/src/google-prompt.ts +82 -0
  22. package/src/google-provider.ts +42 -46
  23. package/src/{google-generative-ai-video-model.ts → google-video-model.ts} +5 -5
  24. package/src/{google-generative-ai-video-settings.ts → google-video-settings.ts} +1 -1
  25. package/src/index.ts +28 -10
  26. package/src/internal/index.ts +2 -2
  27. package/src/{map-google-generative-ai-finish-reason.ts → map-google-finish-reason.ts} +1 -1
  28. package/src/google-generative-ai-prompt.ts +0 -82
@@ -1,12 +1,12 @@
1
1
  ---
2
- title: Google Generative AI
3
- description: Learn how to use Google Generative AI Provider.
2
+ title: Google
3
+ description: Learn how to use Google Provider.
4
4
  ---
5
5
 
6
- # Google Generative AI Provider
6
+ # Google Provider
7
7
 
8
- The [Google Generative AI](https://ai.google.dev) provider contains language and embedding model support for
9
- the [Google Generative AI](https://ai.google.dev/api/rest) APIs.
8
+ The [Google](https://ai.google.dev) provider contains language and embedding model support for
9
+ the [Google](https://ai.google.dev/api/rest) APIs.
10
10
 
11
11
  ## Setup
12
12
 
@@ -36,17 +36,17 @@ You can import the default provider instance `google` from `@ai-sdk/google`:
36
36
  import { google } from '@ai-sdk/google';
37
37
  ```
38
38
 
39
- If you need a customized setup, you can import `createGoogleGenerativeAI` from `@ai-sdk/google` and create a provider instance with your settings:
39
+ If you need a customized setup, you can import `createGoogle` from `@ai-sdk/google` and create a provider instance with your settings:
40
40
 
41
41
  ```ts
42
- import { createGoogleGenerativeAI } from '@ai-sdk/google';
42
+ import { createGoogle } from '@ai-sdk/google';
43
43
 
44
- const google = createGoogleGenerativeAI({
44
+ const google = createGoogle({
45
45
  // custom settings
46
46
  });
47
47
  ```
48
48
 
49
- You can use the following optional settings to customize the Google Generative AI provider instance:
49
+ You can use the following optional settings to customize the Google provider instance:
50
50
 
51
51
  - **baseURL** _string_
52
52
 
@@ -89,7 +89,7 @@ The models support tool calls and some have multi-modal capabilities.
89
89
  const model = google('gemini-2.5-flash');
90
90
  ```
91
91
 
92
- You can use Google Generative AI language models to generate text with the `generateText` function:
92
+ You can use Google language models to generate text with the `generateText` function:
93
93
 
94
94
  ```ts
95
95
  import { google } from '@ai-sdk/google';
@@ -101,11 +101,11 @@ const { text } = await generateText({
101
101
  });
102
102
  ```
103
103
 
104
- Google Generative AI language models can also be used in the `streamText` function
104
+ Google language models can also be used in the `streamText` function
105
105
  and support structured data generation with [`Output`](/docs/reference/ai-sdk-core/output)
106
106
  (see [AI SDK Core](/docs/ai-sdk-core)).
107
107
 
108
- Google Generative AI also supports some model specific settings that are not part of the [standard call settings](/docs/ai-sdk-core/settings).
108
+ Google also supports some model specific settings that are not part of the [standard call settings](/docs/ai-sdk-core/settings).
109
109
  You can pass them as an options argument:
110
110
 
111
111
  ```ts
@@ -128,7 +128,7 @@ await generateText({
128
128
  });
129
129
  ```
130
130
 
131
- The following optional provider options are available for Google Generative AI models:
131
+ The following optional provider options are available for Google models:
132
132
 
133
133
  - **cachedContent** _string_
134
134
 
@@ -141,7 +141,7 @@ The following optional provider options are available for Google Generative AI m
141
141
 
142
142
  This is useful when the JSON Schema contains elements that are
143
143
  not supported by the OpenAPI schema version that
144
- Google Generative AI uses. You can use this to disable
144
+ Google uses. You can use this to disable
145
145
  structured outputs if you need to.
146
146
 
147
147
  See [Troubleshooting: Schema Limitations](#schema-limitations) for more details.
@@ -177,7 +177,7 @@ The following optional provider options are available for Google Generative AI m
177
177
 
178
178
  - **thinkingConfig** _\{ thinkingLevel?: 'minimal' | 'low' | 'medium' | 'high'; thinkingBudget?: number; includeThoughts?: boolean \}_
179
179
 
180
- Optional. Configuration for the model's thinking process. Only supported by specific [Google Generative AI models](https://ai.google.dev/gemini-api/docs/thinking).
180
+ Optional. Configuration for the model's thinking process. Only supported by specific [Google models](https://ai.google.dev/gemini-api/docs/thinking).
181
181
 
182
182
  - **thinkingLevel** _'minimal' | 'low' | 'medium' | 'high'_
183
183
 
@@ -186,7 +186,7 @@ The following optional provider options are available for Google Generative AI m
186
186
  - **thinkingBudget** _number_
187
187
 
188
188
  Optional. Gives the model guidance on the number of thinking tokens it can use when generating a response. Setting it to 0 disables thinking, if the model supports it.
189
- For more information about the possible value ranges for each model see [Google Generative AI thinking documentation](https://ai.google.dev/gemini-api/docs/thinking#set-budget).
189
+ For more information about the possible value ranges for each model see [Google thinking documentation](https://ai.google.dev/gemini-api/docs/thinking#set-budget).
190
190
 
191
191
  <Note>
192
192
  This option is for Gemini 2.5 models. Gemini 3 models should use
@@ -199,7 +199,7 @@ The following optional provider options are available for Google Generative AI m
199
199
 
200
200
  - **imageConfig** _\{ aspectRatio?: string, imageSize?: string \}_
201
201
 
202
- Optional. Configuration for the models image generation. Only supported by specific [Google Generative AI models](https://ai.google.dev/gemini-api/docs/image-generation).
202
+ Optional. Configuration for the models image generation. Only supported by specific [Google models](https://ai.google.dev/gemini-api/docs/image-generation).
203
203
 
204
204
  - **aspectRatio** _string_
205
205
 
@@ -258,7 +258,7 @@ The following optional provider options are available for Google Generative AI m
258
258
 
259
259
  ### Thinking
260
260
 
261
- The Gemini 2.5 and Gemini 3 series models use an internal "thinking process" that significantly improves their reasoning and multi-step planning abilities, making them highly effective for complex tasks such as coding, advanced mathematics, and data analysis. For more information see [Google Generative AI thinking documentation](https://ai.google.dev/gemini-api/docs/thinking).
261
+ The Gemini 2.5 and Gemini 3 series models use an internal "thinking process" that significantly improves their reasoning and multi-step planning abilities, making them highly effective for complex tasks such as coding, advanced mathematics, and data analysis. For more information see [Google thinking documentation](https://ai.google.dev/gemini-api/docs/thinking).
262
262
 
263
263
  #### Gemini 3 Models
264
264
 
@@ -318,7 +318,7 @@ console.log(reasoning); // Reasoning summary
318
318
 
319
319
  ### File Inputs
320
320
 
321
- The Google Generative AI provider supports file inputs, e.g. PDF files.
321
+ The Google provider supports file inputs, e.g. PDF files.
322
322
 
323
323
  ```ts
324
324
  import { google } from '@ai-sdk/google';
@@ -384,7 +384,7 @@ See [File Parts](/docs/foundations/prompts#file-parts) for details on how to use
384
384
 
385
385
  ### Cached Content
386
386
 
387
- Google Generative AI supports both explicit and implicit caching to help reduce costs on repetitive content.
387
+ Google supports both explicit and implicit caching to help reduce costs on repetitive content.
388
388
 
389
389
  #### Implicit Caching
390
390
 
@@ -516,7 +516,7 @@ the model has access to the latest information using Google Search.
516
516
 
517
517
  ```ts highlight="8,17-20"
518
518
  import { google } from '@ai-sdk/google';
519
- import { GoogleGenerativeAIProviderMetadata } from '@ai-sdk/google';
519
+ import { GoogleProviderMetadata } from '@ai-sdk/google';
520
520
  import { generateText } from 'ai';
521
521
 
522
522
  const { text, sources, providerMetadata } = await generateText({
@@ -532,7 +532,7 @@ const { text, sources, providerMetadata } = await generateText({
532
532
  // access the grounding metadata. Casting to the provider metadata type
533
533
  // is optional but provides autocomplete and type safety.
534
534
  const metadata = providerMetadata?.google as
535
- | GoogleGenerativeAIProviderMetadata
535
+ | GoogleProviderMetadata
536
536
  | undefined;
537
537
  const groundingMetadata = metadata?.groundingMetadata;
538
538
  const safetyRatings = metadata?.safetyRatings;
@@ -693,7 +693,7 @@ const { text, sources, providerMetadata } = await generateText({
693
693
  });
694
694
 
695
695
  const metadata = providerMetadata?.google as
696
- | GoogleGenerativeAIProviderMetadata
696
+ | GoogleProviderMetadata
697
697
  | undefined;
698
698
  const groundingMetadata = metadata?.groundingMetadata;
699
699
  const urlContextMetadata = metadata?.urlContextMetadata;
@@ -714,7 +714,7 @@ Example response:
714
714
  {
715
715
  "urlMetadata": [
716
716
  {
717
- "retrievedUrl": "https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai",
717
+ "retrievedUrl": "https://ai-sdk.dev/providers/ai-sdk-providers/google",
718
718
  "urlRetrievalStatus": "URL_RETRIEVAL_STATUS_SUCCESS"
719
719
  }
720
720
  ]
@@ -728,8 +728,8 @@ With the URL context tool, you will also get the `groundingMetadata`.
728
728
  "groundingChunks": [
729
729
  {
730
730
  "web": {
731
- "uri": "https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai",
732
- "title": "Google Generative AI - AI SDK Providers"
731
+ "uri": "https://ai-sdk.dev/providers/ai-sdk-providers/google",
732
+ "title": "Google - AI SDK Providers"
733
733
  }
734
734
  }
735
735
  ],
@@ -766,7 +766,7 @@ import { generateText } from 'ai';
766
766
 
767
767
  const { text, sources, providerMetadata } = await generateText({
768
768
  model: google('gemini-2.5-flash'),
769
- prompt: `Based on this context: https://ai-sdk.dev/providers/ai-sdk-providers/google-generative-ai, tell me how to use Gemini with AI SDK.
769
+ prompt: `Based on this context: https://ai-sdk.dev/providers/ai-sdk-providers/google, tell me how to use Gemini with AI SDK.
770
770
  Also, provide the latest news about AI SDK V5.`,
771
771
  tools: {
772
772
  google_search: google.tools.googleSearch({}),
@@ -775,7 +775,7 @@ const { text, sources, providerMetadata } = await generateText({
775
775
  });
776
776
 
777
777
  const metadata = providerMetadata?.google as
778
- | GoogleGenerativeAIProviderMetadata
778
+ | GoogleProviderMetadata
779
779
  | undefined;
780
780
  const groundingMetadata = metadata?.groundingMetadata;
781
781
  const urlContextMetadata = metadata?.urlContextMetadata;
@@ -788,7 +788,7 @@ the model has access to Google Maps data for location-aware responses. This enab
788
788
 
789
789
  ```ts highlight="7-16"
790
790
  import { google, type GoogleLanguageModelOptions } from '@ai-sdk/google';
791
- import { GoogleGenerativeAIProviderMetadata } from '@ai-sdk/google';
791
+ import { GoogleProviderMetadata } from '@ai-sdk/google';
792
792
  import { generateText } from 'ai';
793
793
 
794
794
  const { text, sources, providerMetadata } = await generateText({
@@ -808,7 +808,7 @@ const { text, sources, providerMetadata } = await generateText({
808
808
  });
809
809
 
810
810
  const metadata = providerMetadata?.google as
811
- | GoogleGenerativeAIProviderMetadata
811
+ | GoogleProviderMetadata
812
812
  | undefined;
813
813
  const groundingMetadata = metadata?.groundingMetadata;
814
814
  ```
@@ -849,7 +849,7 @@ This enables the model to provide answers based on your specific data sources an
849
849
 
850
850
  ```ts highlight="8,17-20"
851
851
  import { createVertex } from '@ai-sdk/google-vertex';
852
- import { GoogleGenerativeAIProviderMetadata } from '@ai-sdk/google';
852
+ import { GoogleProviderMetadata } from '@ai-sdk/google';
853
853
  import { generateText } from 'ai';
854
854
 
855
855
  const vertex = createVertex({
@@ -873,7 +873,7 @@ const { text, sources, providerMetadata } = await generateText({
873
873
  // access the grounding metadata. Casting to the provider metadata type
874
874
  // is optional but provides autocomplete and type safety.
875
875
  const metadata = providerMetadata?.google as
876
- | GoogleGenerativeAIProviderMetadata
876
+ | GoogleProviderMetadata
877
877
  | undefined;
878
878
  const groundingMetadata = metadata?.groundingMetadata;
879
879
  const safetyRatings = metadata?.safetyRatings;
@@ -1057,7 +1057,7 @@ const { output } = await generateText({
1057
1057
  });
1058
1058
  ```
1059
1059
 
1060
- The following Zod features are known to not work with Google Generative AI:
1060
+ The following Zod features are known to not work with Google:
1061
1061
 
1062
1062
  - `z.union`
1063
1063
  - `z.record`
@@ -1117,12 +1117,12 @@ using the `.embedding()` factory method.
1117
1117
  const model = google.embedding('gemini-embedding-001');
1118
1118
  ```
1119
1119
 
1120
- The Google Generative AI provider sends API calls to the right endpoint based on the type of embedding:
1120
+ The Google provider sends API calls to the right endpoint based on the type of embedding:
1121
1121
 
1122
1122
  - **Single embeddings**: When embedding a single value with `embed()`, the provider uses the single `:embedContent` endpoint, which typically has higher rate limits compared to the batch endpoint.
1123
1123
  - **Batch embeddings**: When embedding multiple values with `embedMany()` or multiple values in `embed()`, the provider uses the `:batchEmbedContents` endpoint.
1124
1124
 
1125
- Google Generative AI embedding models support additional settings. You can pass them as an options argument:
1125
+ Google embedding models support additional settings. You can pass them as an options argument:
1126
1126
 
1127
1127
  ```ts
1128
1128
  import { google, type GoogleEmbeddingModelOptions } from '@ai-sdk/google';
@@ -1164,7 +1164,7 @@ const { embeddings } = await embedMany({
1164
1164
  });
1165
1165
  ```
1166
1166
 
1167
- The following optional provider options are available for Google Generative AI embedding models:
1167
+ The following optional provider options are available for Google embedding models:
1168
1168
 
1169
1169
  - **outputDimensionality**: _number_
1170
1170
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ai-sdk/google",
3
- "version": "4.0.0-beta.43",
3
+ "version": "4.0.0-beta.45",
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.0-beta.12",
39
- "@ai-sdk/provider-utils": "5.0.0-beta.24"
39
+ "@ai-sdk/provider-utils": "5.0.0-beta.26"
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/node": "20.17.24",
@@ -1,23 +1,23 @@
1
1
  import { LanguageModelV4Usage } from '@ai-sdk/provider';
2
2
 
3
- export type GoogleGenerativeAITokenDetail = {
3
+ export type GoogleTokenDetail = {
4
4
  modality: string;
5
5
  tokenCount: number;
6
6
  };
7
7
 
8
- export type GoogleGenerativeAIUsageMetadata = {
8
+ export type GoogleUsageMetadata = {
9
9
  promptTokenCount?: number | null;
10
10
  candidatesTokenCount?: number | null;
11
11
  totalTokenCount?: number | null;
12
12
  cachedContentTokenCount?: number | null;
13
13
  thoughtsTokenCount?: number | null;
14
14
  trafficType?: string | null;
15
- promptTokensDetails?: GoogleGenerativeAITokenDetail[] | null;
16
- candidatesTokensDetails?: GoogleGenerativeAITokenDetail[] | null;
15
+ promptTokensDetails?: GoogleTokenDetail[] | null;
16
+ candidatesTokensDetails?: GoogleTokenDetail[] | null;
17
17
  };
18
18
 
19
- export function convertGoogleGenerativeAIUsage(
20
- usage: GoogleGenerativeAIUsageMetadata | undefined | null,
19
+ export function convertGoogleUsage(
20
+ usage: GoogleUsageMetadata | undefined | null,
21
21
  ): LanguageModelV4Usage {
22
22
  if (usage == null) {
23
23
  return {
@@ -8,11 +8,11 @@ import {
8
8
  resolveProviderReference,
9
9
  } from '@ai-sdk/provider-utils';
10
10
  import {
11
- GoogleGenerativeAIContent,
12
- GoogleGenerativeAIContentPart,
13
- GoogleGenerativeAIFunctionResponsePart,
14
- GoogleGenerativeAIPrompt,
15
- } from './google-generative-ai-prompt';
11
+ GoogleContent,
12
+ GoogleContentPart,
13
+ GoogleFunctionResponsePart,
14
+ GooglePrompt,
15
+ } from './google-prompt';
16
16
 
17
17
  const dataUrlRegex = /^data:([^;,]+);base64,(.+)$/s;
18
18
 
@@ -32,7 +32,7 @@ function parseBase64DataUrl(
32
32
 
33
33
  function convertUrlToolResultPart(
34
34
  url: string,
35
- ): GoogleGenerativeAIFunctionResponsePart | undefined {
35
+ ): GoogleFunctionResponsePart | undefined {
36
36
  // Per https://ai.google.dev/api/caching#FunctionResponsePart, only inline data is supported.
37
37
  // https://docs.cloud.google.com/vertex-ai/generative-ai/docs/model-reference/function-calling#functionresponsepart suggests that this
38
38
  // may be different for Vertex, but this needs to be confirmed and further tested for both APIs.
@@ -55,14 +55,14 @@ function convertUrlToolResultPart(
55
55
  * text). This format is supported by Gemini 3+ models.
56
56
  */
57
57
  function appendToolResultParts(
58
- parts: GoogleGenerativeAIContentPart[],
58
+ parts: GoogleContentPart[],
59
59
  toolName: string,
60
60
  outputValue: Array<{
61
61
  type: string;
62
62
  [key: string]: unknown;
63
63
  }>,
64
64
  ): void {
65
- const functionResponseParts: GoogleGenerativeAIFunctionResponsePart[] = [];
65
+ const functionResponseParts: GoogleFunctionResponsePart[] = [];
66
66
  const responseTextParts: string[] = [];
67
67
 
68
68
  for (const contentPart of outputValue) {
@@ -122,7 +122,7 @@ function appendToolResultParts(
122
122
  * non-text content like images is sent as separate top-level inlineData parts.
123
123
  */
124
124
  function appendLegacyToolResultParts(
125
- parts: GoogleGenerativeAIContentPart[],
125
+ parts: GoogleContentPart[],
126
126
  toolName: string,
127
127
  outputValue: Array<{
128
128
  type: string;
@@ -166,16 +166,16 @@ function appendLegacyToolResultParts(
166
166
  }
167
167
  }
168
168
 
169
- export function convertToGoogleGenerativeAIMessages(
169
+ export function convertToGoogleMessages(
170
170
  prompt: LanguageModelV4Prompt,
171
171
  options?: {
172
172
  isGemmaModel?: boolean;
173
173
  providerOptionsName?: string;
174
174
  supportsFunctionResponseParts?: boolean;
175
175
  },
176
- ): GoogleGenerativeAIPrompt {
176
+ ): GooglePrompt {
177
177
  const systemInstructionParts: Array<{ text: string }> = [];
178
- const contents: Array<GoogleGenerativeAIContent> = [];
178
+ const contents: Array<GoogleContent> = [];
179
179
  let systemMessagesAllowed = true;
180
180
  const isGemmaModel = options?.isGemmaModel ?? false;
181
181
  const providerOptionsName = options?.providerOptionsName ?? 'google';
@@ -199,7 +199,7 @@ export function convertToGoogleGenerativeAIMessages(
199
199
  case 'user': {
200
200
  systemMessagesAllowed = false;
201
201
 
202
- const parts: GoogleGenerativeAIContentPart[] = [];
202
+ const parts: GoogleContentPart[] = [];
203
203
 
204
204
  for (const part of content) {
205
205
  switch (part.type) {
@@ -418,7 +418,7 @@ export function convertToGoogleGenerativeAIMessages(
418
418
  case 'tool': {
419
419
  systemMessagesAllowed = false;
420
420
 
421
- const parts: GoogleGenerativeAIContentPart[] = [];
421
+ const parts: GoogleContentPart[] = [];
422
422
 
423
423
  for (const part of content) {
424
424
  if (part.type === 'tool-approval-response') {
@@ -18,26 +18,26 @@ import {
18
18
  import { z } from 'zod/v4';
19
19
  import { googleFailedResponseHandler } from './google-error';
20
20
  import {
21
- GoogleGenerativeAIEmbeddingModelId,
21
+ GoogleEmbeddingModelId,
22
22
  googleEmbeddingModelOptions,
23
- } from './google-generative-ai-embedding-options';
23
+ } from './google-embedding-options';
24
24
 
25
- type GoogleGenerativeAIEmbeddingConfig = {
25
+ type GoogleEmbeddingConfig = {
26
26
  provider: string;
27
27
  baseURL: string;
28
28
  headers?: () => Record<string, string | undefined>;
29
29
  fetch?: FetchFunction;
30
30
  };
31
31
 
32
- export class GoogleGenerativeAIEmbeddingModel implements EmbeddingModelV4 {
32
+ export class GoogleEmbeddingModel implements EmbeddingModelV4 {
33
33
  readonly specificationVersion = 'v4';
34
- readonly modelId: GoogleGenerativeAIEmbeddingModelId;
34
+ readonly modelId: GoogleEmbeddingModelId;
35
35
  readonly maxEmbeddingsPerCall = 2048;
36
36
  readonly supportsParallelCalls = true;
37
37
 
38
- private readonly config: GoogleGenerativeAIEmbeddingConfig;
38
+ private readonly config: GoogleEmbeddingConfig;
39
39
 
40
- static [WORKFLOW_SERIALIZE](model: GoogleGenerativeAIEmbeddingModel) {
40
+ static [WORKFLOW_SERIALIZE](model: GoogleEmbeddingModel) {
41
41
  return serializeModelOptions({
42
42
  modelId: model.modelId,
43
43
  config: model.config,
@@ -46,21 +46,15 @@ export class GoogleGenerativeAIEmbeddingModel implements EmbeddingModelV4 {
46
46
 
47
47
  static [WORKFLOW_DESERIALIZE](options: {
48
48
  modelId: string;
49
- config: GoogleGenerativeAIEmbeddingConfig;
49
+ config: GoogleEmbeddingConfig;
50
50
  }) {
51
- return new GoogleGenerativeAIEmbeddingModel(
52
- options.modelId,
53
- options.config,
54
- );
51
+ return new GoogleEmbeddingModel(options.modelId, options.config);
55
52
  }
56
53
 
57
54
  get provider(): string {
58
55
  return this.config.provider;
59
56
  }
60
- constructor(
61
- modelId: GoogleGenerativeAIEmbeddingModelId,
62
- config: GoogleGenerativeAIEmbeddingConfig,
63
- ) {
57
+ constructor(modelId: GoogleEmbeddingModelId, config: GoogleEmbeddingConfig) {
64
58
  this.modelId = modelId;
65
59
  this.config = config;
66
60
  }
@@ -5,7 +5,7 @@ import {
5
5
  } from '@ai-sdk/provider-utils';
6
6
  import { z } from 'zod/v4';
7
7
 
8
- export type GoogleGenerativeAIEmbeddingModelId =
8
+ export type GoogleEmbeddingModelId =
9
9
  | 'gemini-embedding-001'
10
10
  | 'gemini-embedding-2-preview'
11
11
  | (string & {});
@@ -26,21 +26,21 @@ export type GoogleFilesUploadOptions = {
26
26
  [key: string]: unknown;
27
27
  };
28
28
 
29
- interface GoogleGenerativeAIFilesConfig {
29
+ interface GoogleFilesConfig {
30
30
  provider: string;
31
31
  baseURL: string;
32
32
  headers: () => Record<string, string | undefined>;
33
33
  fetch?: FetchFunction;
34
34
  }
35
35
 
36
- export class GoogleGenerativeAIFiles implements FilesV4 {
36
+ export class GoogleFiles implements FilesV4 {
37
37
  readonly specificationVersion = 'v4';
38
38
 
39
39
  get provider(): string {
40
40
  return this.config.provider;
41
41
  }
42
42
 
43
- constructor(private readonly config: GoogleGenerativeAIFilesConfig) {}
43
+ constructor(private readonly config: GoogleFilesConfig) {}
44
44
 
45
45
  async uploadFile(
46
46
  options: FilesV4UploadFileCallOptions,
@@ -23,13 +23,13 @@ import {
23
23
  import { z } from 'zod/v4';
24
24
  import { googleFailedResponseHandler } from './google-error';
25
25
  import {
26
- GoogleGenerativeAIImageModelId,
27
- GoogleGenerativeAIImageSettings,
28
- } from './google-generative-ai-image-settings';
29
- import { GoogleGenerativeAILanguageModel } from './google-generative-ai-language-model';
30
- import type { GoogleLanguageModelOptions } from './google-generative-ai-options';
26
+ GoogleImageModelId,
27
+ GoogleImageSettings,
28
+ } from './google-image-settings';
29
+ import { GoogleLanguageModel } from './google-language-model';
30
+ import type { GoogleLanguageModelOptions } from './google-options';
31
31
 
32
- interface GoogleGenerativeAIImageModelConfig {
32
+ interface GoogleImageModelConfig {
33
33
  provider: string;
34
34
  baseURL: string;
35
35
  headers?: Resolvable<Record<string, string | undefined>>;
@@ -40,10 +40,10 @@ interface GoogleGenerativeAIImageModelConfig {
40
40
  };
41
41
  }
42
42
 
43
- export class GoogleGenerativeAIImageModel implements ImageModelV4 {
43
+ export class GoogleImageModel implements ImageModelV4 {
44
44
  readonly specificationVersion = 'v4';
45
45
 
46
- static [WORKFLOW_SERIALIZE](model: GoogleGenerativeAIImageModel) {
46
+ static [WORKFLOW_SERIALIZE](model: GoogleImageModel) {
47
47
  return serializeModelOptions({
48
48
  modelId: model.modelId,
49
49
  config: model.config,
@@ -52,13 +52,9 @@ export class GoogleGenerativeAIImageModel implements ImageModelV4 {
52
52
 
53
53
  static [WORKFLOW_DESERIALIZE](options: {
54
54
  modelId: string;
55
- config: GoogleGenerativeAIImageModelConfig;
55
+ config: GoogleImageModelConfig;
56
56
  }) {
57
- return new GoogleGenerativeAIImageModel(
58
- options.modelId,
59
- {},
60
- options.config,
61
- );
57
+ return new GoogleImageModel(options.modelId, {}, options.config);
62
58
  }
63
59
 
64
60
  get maxImagesPerCall(): number {
@@ -78,9 +74,9 @@ export class GoogleGenerativeAIImageModel implements ImageModelV4 {
78
74
  }
79
75
 
80
76
  constructor(
81
- readonly modelId: GoogleGenerativeAIImageModelId,
82
- private readonly settings: GoogleGenerativeAIImageSettings,
83
- private readonly config: GoogleGenerativeAIImageModelConfig,
77
+ readonly modelId: GoogleImageModelId,
78
+ private readonly settings: GoogleImageSettings,
79
+ private readonly config: GoogleImageModelConfig,
84
80
  ) {}
85
81
 
86
82
  async doGenerate(
@@ -113,14 +109,14 @@ export class GoogleGenerativeAIImageModel implements ImageModelV4 {
113
109
  // Imagen API endpoints do not support image editing
114
110
  if (files != null && files.length > 0) {
115
111
  throw new Error(
116
- 'Google Generative AI does not support image editing with Imagen models. ' +
112
+ 'Google Gemini API does not support image editing with Imagen models. ' +
117
113
  'Use Google Vertex AI (@ai-sdk/google-vertex) for image editing capabilities.',
118
114
  );
119
115
  }
120
116
 
121
117
  if (mask != null) {
122
118
  throw new Error(
123
- 'Google Generative AI does not support image editing with masks. ' +
119
+ 'Google Gemini API does not support image editing with masks. ' +
124
120
  'Use Google Vertex AI (@ai-sdk/google-vertex) for image editing capabilities.',
125
121
  );
126
122
  }
@@ -282,7 +278,7 @@ export class GoogleGenerativeAIImageModel implements ImageModelV4 {
282
278
  ];
283
279
 
284
280
  // Instantiate language model
285
- const languageModel = new GoogleGenerativeAILanguageModel(this.modelId, {
281
+ const languageModel = new GoogleLanguageModel(this.modelId, {
286
282
  provider: this.config.provider,
287
283
  baseURL: this.config.baseURL,
288
284
  headers: this.config.headers ?? {},
@@ -1,4 +1,4 @@
1
- export type GoogleGenerativeAIImageModelId =
1
+ export type GoogleImageModelId =
2
2
  // Imagen models (use :predict API)
3
3
  | 'imagen-4.0-generate-001'
4
4
  | 'imagen-4.0-ultra-generate-001'
@@ -9,7 +9,7 @@ export type GoogleGenerativeAIImageModelId =
9
9
  | 'gemini-3.1-flash-image-preview'
10
10
  | (string & {});
11
11
 
12
- export interface GoogleGenerativeAIImageSettings {
12
+ export interface GoogleImageSettings {
13
13
  /**
14
14
  * Override the maximum number of images per call (default 4)
15
15
  */