Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@ai-sdk/google

vercel2.7mApache-2.02.0.23TypeScript support: included

The Google Generative AI provider for the AI SDK contains language model support for the Google Generative AI

ai

readme

packages/ai/README.md

changelog

@ai-sdk/google

2.0.23

Patch Changes

  • 8a1d648: Fix adding google search along with url context in vertex ai

2.0.22

Patch Changes

  • f8da995: The mediaResolution option has been added and is now passed to the Google API.

2.0.21

Patch Changes

  • 53f53c1: Support imageConfig.aspectRatio configuration for Gemini models

2.0.20

Patch Changes

2.0.19

Patch Changes

  • a107843: fix(provider/google): lazy schema loading

    import time improved by 12.5% (22.3ms ➡️ 19.5ms)

2.0.18

Patch Changes

2.0.17

Patch Changes

  • bc5ed71: chore: update zod peer depenedency version
  • 356c1f2: chore (provider/google): Add preview modelIds for gemini 2.5 flash and lite
  • Updated dependencies [bc5ed71]

2.0.16

Patch Changes

  • 322901b: feat: add provider version to user-agent header

2.0.15

Patch Changes

  • 967c463: add promptFeedback outputs

2.0.14

Patch Changes

2.0.13

Patch Changes

  • 5a3ef3a: Fixed handling of image response in the tool call result.

2.0.12

Patch Changes

2.0.11

Patch Changes

  • a14fc2b: feat(provider/google): add gemini 2.5 flash image preview model support

2.0.10

Patch Changes

2.0.9

Patch Changes

2.0.8

Patch Changes

2.0.7

Patch Changes

2.0.6

Patch Changes

2.0.5

Patch Changes

2.0.4

Patch Changes

  • 961dda1: add labels field to providerOptions

2.0.3

Patch Changes

  • 9fb0252: fix(google): add thought signature support for reasoning

2.0.2

Patch Changes

2.0.1

Patch Changes

  • f5464aa: feat(google): update docs + add YouTube URL support to Google Generative AI provider

2.0.0

Major Changes

  • d5f588f: AI SDK 5

Patch Changes

  • 78e7fa9: Add code execution provider defined tool
  • f916255: feat (provider/google): add new gemini models
  • 19a4336: Expose raw usageMetadata returned from Google Generative AI in providerMetadata
  • 8af9e03: Added Image Models to the Google Provider for Imagen 3 Support
  • 1a635b5: update supportedUrls to only support native URL
  • 888b750: feat(providers/google): Add taskType support for Text Embedding Models
  • 3259565: feat (providers/google): add thinking config to provider options
  • e2aceaf: feat: add raw chunk support
  • eb173f1: chore (providers): remove model shorthand deprecation warnings
  • 6a16dcf: embed() now uses the single embeddings endpoint No code updates are needed.

    This is to make sure that users are not ratelimited when using the batch endpoint, since many models have different limits for batch and single embeddings.

    Eg: Google has a limit of 150 RPM for batch requests, and 1500 RPM for single requests.

    Before, AI SDK would always use the batch endpoint, even for embed() calls, which led to ratelimits.

    This does not have any breaking functionality and is fully tested :) if (values.length > 1) { const batchResult = await this.doEmbedBatch({ values, options, }); return batchResult; }

  • 26735b5: chore(embedding-model): add v2 interface

  • 5cf30ea: fix (provider/google): allow "OFF" for Google HarmBlockThreshold
  • 443d8ec: feat(embedding-model-v2): add response body field
  • c68931f: Support tool schemas that allow additional properties (e.g z.record(z.string()))
  • 66962ed: fix(packages): export node10 compatible types
  • a313780: fix: omit system message for gemma models
  • fd98925: chore(providers/google): update embedding model to use providerOptions
  • cb787ac: fix: remove non-functional models
  • 7378473: chore(providers/google): switch to providerOptions
  • f07a6d4: fix(providers/google): accept nullish in safetyRatings
  • 75f03b1: Add Gemini 2.5 Flash Lite GA
  • 779d916: feat: add provider option schemas for vertex imagegen and google genai
  • 581a9be: fix (provider/google): prevent error when thinking signature is used
  • 2e06f14: feat (provider/google): Change to provider defined tools

    • Change the google search tool to be a provider defined tool
    • Added new URL context tool as a provider defined tool
  • 8e6b69d: feat(providers/google): Add support for Gemini 2.5 Pro and Gemini 2.5 Flash (now stable)

  • 42fcd32: feat(google): automatically handle system instructions for Gemma models
  • d1a034f: feature: using Zod 4 for internal stuff
  • fd65bc6: chore(embedding-model-v2): rename rawResponse to response
  • 878bf45: removes (unsupported) additionalProperties from the Schema sent in the request payloads to Google APIs
  • 0f05690: Add gemini-embedding-001 model, add embedding provider options type export
  • 7badba2: fix(google): grounding streaming sources
  • 205077b: fix: improve Zod compatibility
  • f10304b: feat(tool-calling): don't require the user to have to pass parameters
  • Updated dependencies [a571d6e]
  • Updated dependencies [742b7be]
  • Updated dependencies [e7fcc86]
  • Updated dependencies [7cddb72]
  • Updated dependencies [ccce59b]
  • Updated dependencies [e2b9e4b]
  • Updated dependencies [95857aa]
  • Updated dependencies [45c1ea2]
  • Updated dependencies [6f6bb89]
  • Updated dependencies [060370c]
  • Updated dependencies [dc714f3]
  • Updated dependencies [b5da06a]
  • Updated dependencies [d1a1aa1]
  • Updated dependencies [63f9e9b]
  • Updated dependencies [5d142ab]
  • Updated dependencies [d5f588f]
  • Updated dependencies [e025824]
  • Updated dependencies [0571b98]
  • Updated dependencies [b6b43c7]
  • Updated dependencies [4fef487]
  • Updated dependencies [48d257a]
  • Updated dependencies [0c0c0b3]
  • Updated dependencies [0d2c085]
  • Updated dependencies [40acf9b]
  • Updated dependencies [9222aeb]
  • Updated dependencies [e2aceaf]
  • Updated dependencies [411e483]
  • Updated dependencies [8ba77a7]
  • Updated dependencies [7b3ae3f]
  • Updated dependencies [a166433]
  • Updated dependencies [26735b5]
  • Updated dependencies [443d8ec]
  • Updated dependencies [a8c8bd5]
  • Updated dependencies [abf9a79]
  • Updated dependencies [14c9410]
  • Updated dependencies [e86be6f]
  • Updated dependencies [9bf7291]
  • Updated dependencies [2e13791]
  • Updated dependencies [9f95b35]
  • Updated dependencies [66962ed]
  • Updated dependencies [0d06df6]
  • Updated dependencies [472524a]
  • Updated dependencies [dd3ff01]
  • Updated dependencies [d9c98f4]
  • Updated dependencies [05d2819]
  • Updated dependencies [9301f86]
  • Updated dependencies [0a87932]
  • Updated dependencies [c4a2fec]
  • Updated dependencies [957b739]
  • Updated dependencies [79457bd]
  • Updated dependencies [a3f768e]
  • Updated dependencies [7435eb5]
  • Updated dependencies [8aa9e20]
  • Updated dependencies [4617fab]
  • Updated dependencies [ac34802]
  • Updated dependencies [0054544]
  • Updated dependencies [cb68df0]
  • Updated dependencies [ad80501]
  • Updated dependencies [68ecf2f]
  • Updated dependencies [9e9c809]
  • Updated dependencies [32831c6]
  • Updated dependencies [6dc848c]
  • Updated dependencies [6b98118]
  • Updated dependencies [d0f9495]
  • Updated dependencies [63d791d]
  • Updated dependencies [87b828f]
  • Updated dependencies [3f2f00c]
  • Updated dependencies [bfdca8d]
  • Updated dependencies [0ff02bb]
  • Updated dependencies [7979f7f]
  • Updated dependencies [39a4fab]
  • Updated dependencies [44f4aba]
  • Updated dependencies [9bd5ab5]
  • Updated dependencies [57edfcb]
  • Updated dependencies [faf8446]
  • Updated dependencies [7ea4132]
  • Updated dependencies [d1a034f]
  • Updated dependencies [5c56081]
  • Updated dependencies [fd65bc6]
  • Updated dependencies [023ba40]
  • Updated dependencies [ea7a7c9]
  • Updated dependencies [26535e0]
  • Updated dependencies [e030615]
  • Updated dependencies [5e57fae]
  • Updated dependencies [393138b]
  • Updated dependencies [c57e248]
  • Updated dependencies [88a8ee5]
  • Updated dependencies [41fa418]
  • Updated dependencies [205077b]
  • Updated dependencies [71f938d]
  • Updated dependencies [3795467]
  • Updated dependencies [28a5ed5]
  • Updated dependencies [7182d14]
  • Updated dependencies [c1e6647]
  • Updated dependencies [1766ede]
  • Updated dependencies [811dff3]
  • Updated dependencies [f10304b]
  • Updated dependencies [dd5fd43]
  • Updated dependencies [33f4a6a]
  • Updated dependencies [383cbfa]
  • Updated dependencies [27deb4d]
  • Updated dependencies [c4df419]

2.0.0-beta.19

Patch Changes

2.0.0-beta.18

Patch Changes

2.0.0-beta.17

Patch Changes

2.0.0-beta.16

Patch Changes

2.0.0-beta.15

Patch Changes

2.0.0-beta.14

Patch Changes

  • 75f03b1: Add Gemini 2.5 Flash Lite GA

2.0.0-beta.13

Patch Changes

2.0.0-beta.12

Patch Changes

2.0.0-beta.11

Patch Changes

  • 6a16dcf: embed() now uses the single embeddings endpoint No code updates are needed.

    This is to make sure that users are not ratelimited when using the batch endpoint, since many models have different limits for batch and single embeddings.

    Eg: Google has a limit of 150 RPM for batch requests, and 1500 RPM for single requests.

    Before, AI SDK would always use the batch endpoint, even for embed() calls, which led to ratelimits.

    This does not have any breaking functionality and is fully tested :) if (values.length > 1) { const batchResult = await this.doEmbedBatch({ values, options, }); return batchResult; }

2.0.0-beta.10

Patch Changes

2.0.0-beta.9

Patch Changes

  • 8af9e03: Added Image Models to the Google Provider for Imagen 3 Support

2.0.0-beta.8

Patch Changes

  • 2e06f14: feat (provider/google): Change to provider defined tools

    • Change the google search tool to be a provider defined tool
    • Added new URL context tool as a provider defined tool

2.0.0-beta.7

Patch Changes

  • 19a4336: Expose raw usageMetadata returned from Google Generative AI in providerMetadata

2.0.0-beta.6

Patch Changes

  • 878bf45: removes (unsupported) additionalProperties from the Schema sent in the request payloads to Google APIs

2.0.0-beta.5

Patch Changes

  • 42fcd32: feat(google): automatically handle system instructions for Gemma models

2.0.0-beta.4

Patch Changes

  • c68931f: Support tool schemas that allow additional properties (e.g z.record(z.string()))
  • 8e6b69d: feat(providers/google): Add support for Gemini 2.5 Pro and Gemini 2.5 Flash (now stable)

2.0.0-beta.3

Patch Changes

  • cb787ac: fix: remove non-functional models
  • d1a034f: feature: using Zod 4 for internal stuff
  • Updated dependencies [0571b98]
  • Updated dependencies [39a4fab]
  • Updated dependencies [d1a034f]

2.0.0-beta.2

Patch Changes

  • a313780: fix: omit system message for gemma models

2.0.0-beta.1

Patch Changes

  • Updated dependencies [742b7be]
  • Updated dependencies [7cddb72]
  • Updated dependencies [ccce59b]
  • Updated dependencies [e2b9e4b]
  • Updated dependencies [45c1ea2]
  • Updated dependencies [e025824]
  • Updated dependencies [0d06df6]
  • Updated dependencies [472524a]
  • Updated dependencies [dd3ff01]
  • Updated dependencies [7435eb5]
  • Updated dependencies [cb68df0]
  • Updated dependencies [bfdca8d]
  • Updated dependencies [44f4aba]
  • Updated dependencies [023ba40]
  • Updated dependencies [5e57fae]
  • Updated dependencies [71f938d]
  • Updated dependencies [28a5ed5]

2.0.0-alpha.15

Patch Changes

2.0.0-alpha.14

Patch Changes

2.0.0-alpha.13

Patch Changes

2.0.0-alpha.12

Patch Changes

2.0.0-alpha.11

Patch Changes

2.0.0-alpha.10

Patch Changes

2.0.0-alpha.9

Patch Changes

2.0.0-alpha.8

Patch Changes

2.0.0-alpha.7

Patch Changes

2.0.0-alpha.6

Patch Changes

2.0.0-alpha.4

Patch Changes

2.0.0-alpha.3

Patch Changes

2.0.0-alpha.2

Patch Changes

2.0.0-alpha.1

Patch Changes

2.0.0-canary.20

Patch Changes

2.0.0-canary.19

Patch Changes

2.0.0-canary.18

Patch Changes

2.0.0-canary.17

Patch Changes

2.0.0-canary.16

Patch Changes

2.0.0-canary.15

Patch Changes

2.0.0-canary.14

Patch Changes

2.0.0-canary.13

Patch Changes

2.0.0-canary.12

Patch Changes

2.0.0-canary.11

Patch Changes

2.0.0-canary.10

Patch Changes

2.0.0-canary.9

Patch Changes

2.0.0-canary.8

Patch Changes

  • 26735b5: chore(embedding-model): add v2 interface
  • 443d8ec: feat(embedding-model-v2): add response body field
  • fd65bc6: chore(embedding-model-v2): rename rawResponse to response
  • Updated dependencies [26735b5]
  • Updated dependencies [443d8ec]
  • Updated dependencies [14c9410]
  • Updated dependencies [d9c98f4]
  • Updated dependencies [c4a2fec]
  • Updated dependencies [0054544]
  • Updated dependencies [9e9c809]
  • Updated dependencies [32831c6]
  • Updated dependencies [d0f9495]
  • Updated dependencies [fd65bc6]
  • Updated dependencies [393138b]
  • Updated dependencies [7182d14]

2.0.0-canary.7

Patch Changes

2.0.0-canary.6

Patch Changes

2.0.0-canary.5

Patch Changes

2.0.0-canary.4

Patch Changes

2.0.0-canary.3

Patch Changes

2.0.0-canary.2

Patch Changes

  • 5cf30ea: fix (provider/google): allow "OFF" for Google HarmBlockThreshold

2.0.0-canary.1

Patch Changes

  • 779d916: feat: add provider option schemas for vertex imagegen and google genai
  • Updated dependencies [060370c]
  • Updated dependencies [0c0c0b3]
  • Updated dependencies [63d791d]

2.0.0-canary.0

Major Changes

  • d5f588f: AI SDK 5

Patch Changes

1.2.5

Patch Changes

1.2.4

Patch Changes

1.2.3

Patch Changes

  • 871df87: feat (provider/google): add gemini-2.5-pro-exp-03-25 to model list

1.2.2

Patch Changes

1.2.1

Patch Changes

  • 994a13b: feat (provider/google): support IMAGE_SAFETY finish reason

1.2.0

Minor Changes

  • 5bc638d: AI SDK 4.2

Patch Changes

1.1.27

Patch Changes

1.1.26

Patch Changes

1.1.25

Patch Changes

1.1.24

Patch Changes

  • 5261762: fix (provider/google): ensure correct finishReason for tool calls in streaming response

1.1.23

Patch Changes

  • 413f5a7: feat (providers/google): add gemma 3 model id

1.1.22

Patch Changes

  • 62f46fd: feat (provider/google): add support for dynamic retrieval

1.1.21

Patch Changes

1.1.20

Patch Changes

1.1.19

Patch Changes

  • 2c27583: fix (provider/google): support empty content in malformed function call responses

1.1.18

Patch Changes

  • 5c8f512: feat (provider/google): add seed support

1.1.17

Patch Changes

1.1.16

Patch Changes

  • 1b2e2a0: fix (provider/google): add resilience against undefined parts

1.1.15

Patch Changes

1.1.14

Patch Changes

  • 08a3641: fix (provider/google): support nullable enums in schema

1.1.13

Patch Changes

1.1.12

Patch Changes

1.1.11

Patch Changes

  • 6eb7fc4: feat (ai/core): url source support

1.1.10

Patch Changes

  • e5567f7: feat (provider/google): update model ids

1.1.9

Patch Changes

  • b2573de: fix (provider/google): remove reasoning text following removal from Gemini API

1.1.8

Patch Changes

1.1.7

Patch Changes

  • d399f25: feat (provider/google-vertex): support public file urls in messages

1.1.6

Patch Changes

  • e012cd8: feat (provider/google): add reasoning support

1.1.5

Patch Changes

1.1.4

Patch Changes

1.1.3

Patch Changes

1.1.2

Patch Changes

1.1.1

Patch Changes

1.1.0

Minor Changes

  • 62ba5ad: release: AI SDK 4.1

Patch Changes

1.0.17

Patch Changes

1.0.16

Patch Changes

  • 4eb9b41: fix (provider/google): support conversion of string enums to openapi spec

1.0.15

Patch Changes

  • 7611964: feat (provider/xai): Support structured output for latest models.

1.0.14

Patch Changes

1.0.13

Patch Changes

1.0.12

Patch Changes

1.0.11

Patch Changes

  • db31e74: feat: adding audioTimestamp support to GoogleGenerativeAISettings

1.0.10

Patch Changes

  • e07439a: feat (provider/google): Include safety ratings response detail.
  • 4017b0f: feat (provider/google-vertex): Enhance grounding metadata response detail.
  • a9df182: feat (provider/google): Add support for search grounding.

1.0.9

Patch Changes

  • c0b1c7e: feat (provider/google): Add Gemini 2.0 model.

1.0.8

Patch Changes

  • b7372dc: feat (provider/google): Include optional response grounding metadata.

1.0.7

Patch Changes

1.0.6

Patch Changes

  • 9e54403: fix (provider/google-vertex): support empty object as usage metadata

1.0.5

Patch Changes

  • 0984f0b: feat (provider/google-vertex): Rewrite for Edge runtime support.
  • Updated dependencies [0984f0b]

1.0.4

Patch Changes

  • 6373c60: fix (provider/google): send json schema into provider

1.0.3

Patch Changes

1.0.2

Patch Changes

  • b748dfb: feat (providers): update model lists

1.0.1

Patch Changes

1.0.0

Major Changes

  • 66060f7: chore (release): bump major version to 4.0
  • 0d3d3f5: chore (providers): remove baseUrl option
  • 36b03b0: chore (provider/google): remove topK model setting
  • 277fc6b: chore (provider/google): remove facade

Patch Changes

  • c38a0db: fix (provider/google): allow empty candidates array when streaming
  • 0509c34: fix (provider/google): add name/content details to tool responses
  • Updated dependencies [b469a7e]
  • Updated dependencies [dce4158]
  • Updated dependencies [c0ddc24]
  • Updated dependencies [b1da952]
  • Updated dependencies [dce4158]
  • Updated dependencies [8426f55]
  • Updated dependencies [db46ce5]

1.0.0-canary.6

Patch Changes

  • c38a0db: fix (provider/google): allow empty candidates array when streaming

1.0.0-canary.5

Patch Changes

  • 0509c34: fix (provider/google): add name/content details to tool responses

1.0.0-canary.4

Major Changes

  • 36b03b0: chore (provider/google): remove topK model setting
  • 277fc6b: chore (provider/google): remove facade

1.0.0-canary.3

Patch Changes

1.0.0-canary.2

Patch Changes

1.0.0-canary.1

Major Changes

  • 0d3d3f5: chore (providers): remove baseUrl option

Patch Changes

1.0.0-canary.0

Major Changes

  • 66060f7: chore (release): bump major version to 4.0

Patch Changes

0.0.55

Patch Changes

  • 11beb9d: fix (provider/google): support tool calls without parameters

0.0.54

Patch Changes

  • 1486128: feat: add supportsUrl to language model specification
  • 1486128: feat (provider/google): support native file URLs without download
  • 3b1b69a: feat: provider-defined tools
  • Updated dependencies [aa98cdb]
  • Updated dependencies [1486128]
  • Updated dependencies [7b937c5]
  • Updated dependencies [3b1b69a]
  • Updated dependencies [811a317]

0.0.53

Patch Changes

0.0.52

Patch Changes

  • 7944e61: feat (provider/google): enable frequencyPenalty and presencePenalty settings

0.0.51

Patch Changes

0.0.50

Patch Changes

  • 5d113fb: feat (provider/google): support fine-tuned models

0.0.49

Patch Changes

  • 2e32bd0: fix (provider/google): deal with empty candidatesTokenCount
  • 2e32bd0: feat (provider/google): add new models

0.0.48

Patch Changes

0.0.47

Patch Changes

0.0.46

Patch Changes

0.0.45

Patch Changes

0.0.44

Patch Changes

  • cb94042: fix (provider/google): allow disabling structured generation

0.0.43

Patch Changes

0.0.42

Patch Changes

  • 9c1f4f2: chore (provider/google): remove "models/" from model name

0.0.41

Patch Changes

  • 5da9c7f: feat (provider/google): embedding support

0.0.40

Patch Changes

0.0.39

Patch Changes

0.0.38

Patch Changes

  • 123134b: fix (provider/google): change default object generation mode to json
  • dd712ac: fix: use FetchFunction type to prevent self-reference
  • Updated dependencies [dd712ac]

0.0.37

Patch Changes

0.0.36

Patch Changes

0.0.35

Patch Changes

  • 1e94ed8: feat (provider/google): send json schema in object-json mode

0.0.34

Patch Changes

0.0.33

Patch Changes

0.0.32

Patch Changes

0.0.31

Patch Changes

0.0.30

Patch Changes

0.0.29

Patch Changes

0.0.28

Patch Changes

  • 2b9da0f0: feat (core): support stopSequences setting.
  • a5b58845: feat (core): support topK setting
  • 4aa8deb3: feat (provider): support responseFormat setting in provider api
  • 13b27ec6: chore (ai/core): remove grammar mode
  • Updated dependencies [2b9da0f0]
  • Updated dependencies [a5b58845]
  • Updated dependencies [4aa8deb3]
  • Updated dependencies [13b27ec6]

0.0.27

Patch Changes

  • 2e59d266: feat (provider/google): add cachedContent optional setting
  • d2b9723d: feat (provider/google): support system instructions
  • 4dfe0b00: feat (provider/google): add tool support for object generation (new default mode)

0.0.26

Patch Changes

0.0.25

Patch Changes

0.0.24

Patch Changes

0.0.23

Patch Changes

0.0.22

Patch Changes

0.0.21

Patch Changes

  • 4728c37f: feat (core): add text embedding model support to provider registry
  • 7910ae84: feat (providers): support custom fetch implementations
  • Updated dependencies [7910ae84]

0.0.20

Patch Changes

0.0.19

Patch Changes

0.0.18

Patch Changes

  • 8022d73e: feat (provider/google): add safety setting option on models

0.0.17

Patch Changes

0.0.16

Patch Changes

0.0.15

Patch Changes

0.0.14

Patch Changes

  • df47a34: feat (provider/google): add models/gemini-1.5-flash-latest to list of supported models

0.0.13

Patch Changes

  • 9a7ec8b: feat (provider/google): add token usage information

0.0.12

Patch Changes

0.0.11

Patch Changes

0.0.10

Patch Changes

0.0.9

Patch Changes

0.0.8

Patch Changes

0.0.7

Patch Changes

0.0.6

Patch Changes

0.0.5

Patch Changes

  • c6fc35b: Add custom header support.

0.0.4

Patch Changes

  • ab60b18: Simplified model construction by directly calling provider functions. Add create... functions to create provider instances.

0.0.3

Patch Changes

  • 587240b: Standardize providers to offer .chat() method

0.0.2

Patch Changes

  • 2bff460: Fix build for release.

0.0.1

Patch Changes

  • 7b8791d: Rename baseUrl to baseURL. Automatically remove trailing slashes.
  • Updated dependencies [7b8791d]