Member-only story
Integrating Google’s Gemini API in Laravel is Super Easy
Hello Developers! Today, we will see how to integrate Google’s Gemini API in Laravel. We are going to use the Gemini 1.5 Flash model from Google’s Gemini Family.
According to Google, Gemini 1.5 Flash is a fast and versatile multimodal model for scaling across diverse tasks. You can read more about this model here.
Prerequisites
I am assuming you have already setup your Laravel project or you can setup a new one using the following command.
composer create-project laravel/laravel example-app
Step 1: Obtain the Google API key
First, you need to obtain the Google API key from Google AI Studio. You can follow these steps:
- Open Google AI Studio
Open this link in new tab. - Create an API Key
There, you will find a button labeled Create API key. Click on it. - Select Existing Project
A popup will be opened to select your existingGoogle Cloud Projects
. Select the project in which you want to create an API key. - Create a New Project (if needed)
If you don’t have any existingGoogle Cloud Project
. You will see another button there labeled Create API key in new project. Click on it.