Table of contents

Connecting Gemini—Google’s LLM and formerly known as Bard—with your internal applications and/or product can fundamentally change how your employees interact with your applications and/or how customers use your product.
But before you can access one of Gemini’s models via API requests, you’ll need to generate an API key within the Google AI Studio.
We’ll help you do just that by walking through each of the 5 steps you’ll need to take.
You should see the sign in button on the top right corner of Google’s home page.

{{this-blog-only-cta}}
You can find this landing page here. You'd then need to click on the “Gemini API” tab or click on the “Learn more about the Gemini API” button.
Alternatively, you can visit the Gemini API landing page directly.

Related: How to get your API key from Llama
This should appear as a button on the center of the page.

You should then see a pop-up that asks you to consent to Google APIs Terms of Service and Gemini API Additional Terms of Service.
While not required, you can also opt in to receive emails that keep you up to date on Google AI and ask you to participate in specific research studies for Google AI.

Go ahead and check off the first box (and the others if you’d like) and click Continue.
Related: What you need to do to get your Grok API key
You can now click “Create API key.”

You’ll then have the option to create an API key in a new project or via an existing project.

Once you’ve chosen one of these options, your API key should be auto-generated!

Remember to store this API key in a secure location to prevent unauthorized access.
Related: A guide to getting your API key in Mistral AI
Before building to Gemini’s API, you should also look into and understand the following areas:
The pricing plans vary between Gemini 1.5 Flash, Gemini 1.5 Pro, and Gemini 1.0 Pro. However, they all come with a free tier and a pay-as-you-go tier.
The main differences between the two tiers across these models are the rate limits, the pricing on inputs and outputs, whether context caching is provided, and whether the inputs and outputs are used to improve their products.
You can learn more about Gemini’s pricing plans here.
As mentioned previously, the rate limits differ across models and plans. The rate limits are also measured in several ways for each model and plan. More specifically, they’re measured by requests per minute, tokens per minute, and requests per day.

Learn more about Gemini’s rate limits here.
While you may experience a wide range of errors, here are a few common ones to be aware of:
Learn more about the API errors you might encounter with Gemini here.
To help you build integrations faster and with fewer issues, you can use any one of Gemini API’s SDKs.
Their SDKs cover a wide range of languages, which include Python, Node.js, Go, Dart, Android, Swift, Web, and REST.
You can learn more about the prerequisites of using each SDK, get instructions for installing any, and more here.
Using the Gemini API, you can access a wide range of the LLM’s capabilities.
Here’s just a snapshot of what you can do:
While the Gemini API prevents its output from “core harms”, you can adjust certain safety filters—harassment, hate speech, sexually explicit, and dangerous—in a given request such that the outputs better fit your needs.
You’ll receive the category scores in the API response (low, medium, and high) and, based on these scores, the content may or may not get blocked.
You can learn more about using safety filtering with the Gemini API here.
Merge Gateway is a unified API and control plane for production LLM traffic, with routing, cost controls, and observability built in.

It offers:
Try Merge Gateway for free today!
Dynamically route each request to the best-fit model (including Gemini models) to reduce spend without compromising performance via Merge Gateway.