We use cookies to improve your experience on our site. By clicking “Accept”, you are agreeing to the collection and use of data as described in our Privacy Policy.
We use cookies to improve your experience on our site. By using our site, you are agreeing to the collection and use of data as described in our Privacy Policy.
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.
Step 1: Login to your Google account
You should see the sign in button on the top right corner of Google’s home page.
{{this-blog-only-cta}}
Step 2: Visit the “Google AI Studio”
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.
Step 3: Click on “Get API key in Google AI Studio”
This should appear as a button on the center of the page.
Step 4: Review and approve the terms of service
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.
Before building to Gemini’s API, you should also look into and understand the following areas:
Pricing plans
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.
Rate limits
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.
While you may experience a wide range of errors, here are a few common ones to be aware of:
400 INVALID_ARGUMENT: The request body has a typo, missing field(s), or another issue that’s leading the request to fail
404 NOT_FOUND: your requested resource wasn’t found in the server
403 PERMISSION_DENIED: your API key doesn’t have the appropriate level of permissions to access the model; and/or you’re trying to access a tuned model without going through the proper authentication process
500 INTERNAL: the issue lies on Gemini’s end. You can try making the same request to another model or simply wait and retry the request
Learn more about the API errors you might encounter with Gemini here.
SDKs
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.
Capabilities available
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:
Text generation: Through your inputs, you can get outputs that summarize text, describe visual assets, translate text into a different language, create copy in specific formats (e.g., blog post) and in a certain tone and voice
Vision: You can use an image or video as the input and get summaries of or specific questions answered about that video or image.
Audio: Using an audio recording as the input, you can get a summary of the audio file, receive answers to certain questions, or receive a transcription (you can define the transcription’s length and sections that you'd like)
Long context: Using a Gemini model’s large context window (e.g., 2 million tokens with Gemini 1.5 Pro), you can use long-form text, videos, and audio recordings in your inputs and get answers to specific questions, receive summaries, edit videos in certain ways (e.g., add captions), and more
Safety filters
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.
Leverage Gemini models effectively with Merge Gateway
Merge Gateway is a unified API and control plane for production LLM traffic, with routing, cost controls, and observability built in.
It offers:
Smart routing for efficiency: Automatically steer each request to the best-fit model to lower cost while maintaining quality
Budgeting and guardrails: Set spend limits and usage policies by team, project, or customer tier
Full-fidelity visibility and resiliency: Inspect request-level logs and routing decisions, with automatic fallback when providers degrade
Jon Gitlin is the Managing Editor of Merge's blog. He has several years of experience in the integration and automation space; before Merge, he worked at Workato, an integration platform as a service (iPaaS) solution, where he also managed the company's blog. In his free time he loves to watch soccer matches, go on long runs in parks, and explore local restaurants.
Read more
Introducing the Universal Context Layer: a company brain that works with every AI tool and agent
Product
Instantly cut token spend in half: introducing Merge for Workforce