The 'ai-sdk-provider-gemini-cli' package serves as a community-developed provider for the Vercel AI SDK, enabling seamless integration with Google's Gemini large language models. Unlike direct API clients, this provider leverages the official Google Gemini CLI/SDK, specifically the '@google/gemini-cli-core' package, and utilizes Google Cloud Code endpoints. The current stable version is 2.0.1, offering full compatibility with AI SDK v6. This project maintains an active release cadence, frequently updating to support new Gemini models and AI SDK features. Key differentiators include its reliance on the robust Gemini CLI for authentication and model access, support for multimodal inputs (text, images, PDFs, audio, video), advanced tool/function calling, and native structured output with Zod schemas. It also provides specific configuration options like 'thinkingConfig' for fine-tuning reasoning levels in Gemini 3 models, and a flexible logging system. To use, developers must first globally install and authenticate the '@google/gemini-cli'.
npm install ai-sdk-provider-gemini-cliVerified import paths — ran on the pinned version, not inferred.
Demonstrates basic text generation using the Gemini provider with OAuth authentication and a specific Gemini 3 model, printing a haiku.
Review the AI SDK v6 migration guide and update your provider configuration, model calls, and token/warning handling to match the new interfaces and structures. For AI SDK v5 compatibility, install `ai-sdk-provider-gemini-cli@ai-sdk-v5`.
Upgrade your Node.js environment to version 20 or higher to ensure compatibility and stability.
Run `npm install -g @google/gemini-cli` and then execute `gemini` in your terminal to complete the interactive authentication process.
Always install the provider with the correct NPM tag that matches your project's Vercel AI SDK version (e.g., `npm install ai-sdk-provider-gemini-cli@ai-sdk-v5 ai@^5.0.0` for AI SDK v5).
Upgrade to v2.0.1 or later. If upgrading is not immediately possible, explicitly add `type: "object"` to any function tool parameter schemas that define `properties`.
Run `npm install -g @google/gemini-cli` to install the Gemini CLI globally. Ensure your npm global bin directory is in your system's PATH.
Execute `gemini` in your terminal and follow the interactive prompts to authenticate your Google account via OAuth.
Ensure your `package.json` includes `"type": "module"` for ESM support. Use `import { generateText } from 'ai';` and other ESM import syntax. If using older AI SDK versions, verify your bundler configuration.Use a Gemini model explicitly listed as supporting `responseJsonSchema`, such as `gemini-3-pro-preview`. Ensure your `ai-sdk-provider-gemini-cli` version is `>=1.4.0` for native structured output support.
Upgrade your Node.js installation to version 20 or newer using a version manager like `nvm` (e.g., `nvm install 20 && nvm use 20`).