Customize authentication and provider settings
Set a custom Google API key or other provider configuration.
AI Tools · Function
Creates a customized Google Generative AI provider for the Vercel AI SDK. Use the returned provider to create Google language or embedding models with provider-specific settings.
Use createGoogleGenerativeAI when the default Google provider is insufficient and you need provider-specific settings such as an API key. The returned provider is callable with a model identifier, producing a language model that can be passed to AI SDK functions such as generateText.
createGoogleGenerativeAI(options)| Name | Type | Description |
|---|---|---|
options | provider settings object | Configuration settings for the customized Google Generative AI provider; the page's example passes a settings object but does not enumerate its fields in the fetched excerpt. |
A configured Google Generative AI provider instance that can be called with a model identifier to create models.
import { createGoogleGenerativeAI } from '@ai-sdk/google';
import { generateText } from 'ai';
const google = createGoogleGenerativeAI({
apiKey: process.env.GOOGLE_GENERATIVE_AI_API_KEY,
});
const { text } = await generateText({
model: google('gemini-2.0-flash-exp'),
prompt: 'Explain dependency injection in one sentence.',
});
console.log(text);Creates a configured Google provider and uses it to select a Gemini model for text generation.
Set a custom Google API key or other provider configuration.
Select Gemini models through a configured provider instance.
Use Google Generative AI capabilities while retaining the AI SDK interface.
google@ai-sdk/googleGoogle Generative AI providergenerateText