Google AI
Setup Google Generative AI provider and learn how to use its models like Gemini in the starter kit.
The Google Generative AI provider integrates Google's state-of-the-art models, including the versatile Gemini family, into your applications through the AI SDK.
Setup
Generate API Key
Visit the Google AI Studio to create your API key. For enterprise applications using Google Cloud, you can alternatively configure authentication via Application Default Credentials or service accounts.
Add API Key to Environment
Add your API key to your project's .env
file (e.g., in apps/web
):
If using Google Cloud credentials instead, ensure they're properly configured in your environment.
Configure Provider (Optional)
The starter kit automatically uses the GOOGLE_GENERATIVE_AI_API_KEY
environment variable. For advanced configurations (such as proxies, custom API versions, or specific headers), you can create a tailored provider instance using createGoogleGenerativeAI
. See the AI SDK Google documentation for comprehensive details.
Features
Language Models (Gemini)
Leverage Google's advanced Gemini models for chat, text generation, reasoning, and complex instruction following.
Embedding Models
Utilize text embedding models to convert text into numerical representations for tasks like semantic search, clustering, and RAG.
Vision / File Input
Analyze and understand various file types (including images and PDFs) alongside text prompts, enabling rich multimodal applications with comprehensive content understanding.
Tool Usage / Function Calling
Empower models to interact seamlessly with external tools and APIs, allowing them to perform real-world actions and retrieve up-to-date information for more capable applications.
Safety Settings
Configure safety thresholds to control model responses regarding harmful content categories. Access safety ratings in the response metadata.
Cached Content
Cache content to optimize context reuse and potentially reduce latency and costs for repeated queries with similar context.
Search Grounding
(With compatible models) Ground responses in real-time search results, dramatically enhancing factual accuracy and providing up-to-date information on current topics.
Use Cases
AI Chatbot
Create sophisticated conversational agents powered by Gemini models that can engage in natural dialogue and handle complex, multi-step tasks. Experience this in our Chat Demo.
Content Generation
Generate diverse text formats, from creative writing and marketing copy to code explanations and summaries.
Multimodal Applications
Build applications that seamlessly analyze and understand images, documents, and other file types alongside text, creating richer, more contextual user experiences.
Semantic Search & RAG
Implement powerful search capabilities or sophisticated Retrieval-Augmented Generation systems using Google's high-performance embedding models for more accurate information retrieval.
Automated Workflows
Streamline operations by connecting language models to external tools and APIs through function calling, automating complex business processes and repetitive tasks with minimal human intervention.
Links
How is this guide?
Last updated on