Skip to content
masterclassBuddyTech Buzz5 fresh blogs · 5:00 AM IST

AI Tools · Const

Google Gemini API

The Google provider lets AI SDK applications call Google Gemini models through @ai-sdk/google. Use google(modelId) to create a model for AI SDK generation functions, with authentication supplied by the documented environment variable.

How it works

The Google provider connects AI SDK model calls to Google’s APIs. Import the default provider, pass a Gemini model identifier to it, and use the resulting model with AI SDK functions such as generateText; configure authentication through the provider’s documented API-key environment variable.

Syntax

google(modelId)

Parameters

NameTypeDescription
modelIdstringGoogle model identifier, such as a Gemini model name.

Returns

A language model instance compatible with AI SDK Core generation functions.

Key points

  • The default google provider can create models directly from a model identifier.
  • Call google(modelId) to obtain a model usable with AI SDK generation functions.
  • The provider’s first argument is the Gemini model identifier.
  • Direct integration requires both the core ai package and the Google provider package.

Common mistakes

  • Model strings may use AI Gateway by default; use the direct provider when you specifically need direct Google API access or Google-specific APIs.

Example: Generate text with Gemini

import { generateText } from 'ai';
import { google } from '@ai-sdk/google';

const { text } = await generateText({
  model: google('gemini-2.5-flash'),
  prompt: 'Explain dependency injection in one sentence.',
});

console.log(text);

Generates text with a Google Gemini model through the official Google provider.

When to use it

Text generation

Generate text with a Gemini language model.

Direct Google API access

Connect directly to Google’s Generative AI APIs.

Provider-specific features

Use Google-specific provider capabilities such as the documented interactions API.

  • generateText
  • createGoogle
  • @ai-sdk/google
  • GOOGLE_GENERATIVE_AI_API_KEY
  • AI Gateway

Source: Google - AI SDK. Checked 2026-10-15.