Docs
How to Apply for Gemini API Key and Use AI Chatbot

How to Apply for Gemini API Key and Use AI Chatbot

Learn how to apply for a Gemini API key, and using AI Chatbot with Vercel AI SDK (defaulting to Gemini, with support for OpenAI and other models).

Gemini is Google’s cutting-edge generative language model. In this guide, you'll learn how to apply for a Gemini API key and integrate its powerful features into your projects. We’ll implement an AI Chatbot with the Vercel AI SDK that defaults to Gemini but can also support other models like OpenAI.


How to Apply for a Gemini API Key

  1. Visit the Google AI Platform:
    Go to Google AI Studio and sign in with your Google account.

  2. Create a New Project:
    If you don’t have an existing project, create a new one via the Google Cloud Console.

  3. Enable the Gemini API:
    Navigate to the API Library and search for the Gemini API. Click "Enable" to add it to your project.

  4. Generate an API Key:
    In the Cloud Console, go to the "Credentials" section and click "Create Credentials". Choose "API Key" and copy the generated key.

    Note: Keep your API key secure and restrict its usage via application restrictions and API restrictions.

  5. Set Up Environment Variables:
    Store your API key in a secure place (e.g., in a .env.local file):

    GOOGLE_GENERATIVE_AI_API_KEY=your_generated_api_key_here

How to use AI Chatbot

You can test it in AI Chatbot

and if you set up GOOGLE_GENERATIVE_AI_API_KEY,you can use it directly before you run BuouNext success