Gemini Pro API in Python: Learn to Access using Google API Key
Key Takeaways
Accessing Gemini API using API keys generated from Google AI Studio and Google Cloud Console, and integrating Gemini into a Python application using the Google Generative AI package.
Full Transcript
this is amazing what if you can use Gemini API using API Keys generated from Google AI Studio what if you can use generative AI package to interact with your Gemini API what is the difference between Google AI Studio vertex AI API keys and service account that's exactly what we're going to see today let's get [Music] started hi everyone I'm really excited to show you about gerini AP using API key and also we are going to see the difference between vertex Ai and Google AI Studio I'm going to take you through step by step but before that I regularly create videos in regards to Artificial Intelligence on my YouTube channel so do subscribe and click the Bell icon to stay tuned coming to Gemini API there are two ways of accessing this API One is using Google Cloud console another one is using Google AI Studio Google Cloud console looks like this and here you can create your service account from the I am and admin panel either you grant access to the existing email address or you can create a service account on the left hand side by clicking this icon service account is nothing but email address for our software to use so that is all about Google Cloud console and we use vertex AI python package to interact with API but in regards to Google AI Studio we use Google generative AI python package to interact with the API and we generate API key from Google AI Studio to use Gemini API so Google AI Studio looks like this and you can create your API Key by clicking this button keep a copy of the API key that is required to run the current application which we are going to create now let's dive into the code the first step is cond create iph and gerini python equal 3.11 and click enter then cond activate gerini and click enter next export your Google API key which you have just generated from Google AI Studio here and then click enter next pip install Google generative AI package this is the one used to interact with gini API now let's create a file called app.py and open it inside the file import google. generative AI as gen aai then UT OS the first step is the configuration where you pass your API key to gen ai. configure then you define the temperature top P top K and then Max output tokens the second step is initializing the model here gen. generative model we are defining the model name and passing the generation config and the third step is to generate content that means ask questions to the large language model to do that response equals model. generate content and I'm asking a question create a meal plan for today and finally you're printing out the response so this is similar to vertex AI API which I've shown before which I will link that in the description below in this we are importing generative AI package defining the configuration initializing the model using gen. generative model and then ask you to generate content by asking a question now we're going to run this code in your terminal Python app.py and click enter now we got breakfast lunch dinner snacks and other tips now we're going to see how we can stream this response to do that I'm adding Chunk in response and then printing the output now going to delete this line now going back to our terminal Python app.py and click enter now it's going to stream it streamed very quickly that you couldn't see the streamed response now we are going to use gini Vision API so we're going to change the model name to gini Pro Vision then we are going to import the path from path lib next we are going to change the output is print response. txt the configurations remain the same in the generate content step we are going to import image image path equals path image. jpeg next we are reading bytes from that image next we're going to create prompt Parts which contains the question to ask about the image and the image so the question we going to ask is describe what the people are doing in this image so this is the image and we going to describe what the people are doing and finally response equals model. generate content and passing the prompts it's multimodal so it can accept text and image and finally printing the response now we're going to run this code in your terminal Python app.py and click enter here is the answer two men are playing Cricket the man in the foreground is the batsman and the Man in the background is the Wicket keeper the batsman is about to hit the ball with this bat the Wicket keeper is standing behind the stumps and ready to catch the ball if the batsman misses it that's it as simple simple as that now you are able to integrate Gemini into your own python application I'm going to create more videos similar to this so stay tuned I hope you like this video do like share and subscribe and thanks for watching
Original Description
🚀 In this comprehensive tutorial, we delve into the exciting world of the Gemini API and how to use it with API keys generated from Google AI Studio. Whether you're a beginner or an advanced user, this video is tailored to provide you with a clear understanding of the interaction between generative AI packages and the Gemini API. We compare Google AI Studio and Vertex AI, exploring their differences in API keys and service accounts.
👩💻 Starting with an introduction to the Gemini API and its access methods, we guide you through creating service accounts in Google Cloud Console, and utilizing Python packages for effective API interaction. Our step-by-step process includes detailed instructions on setting up your environment, generating API keys, and writing Python code to interact with the API.
Gemini Playlist: https://www.youtube.com/playlist?list=PLYQsp-tXX9w63Xe06j_gevoVTQ2ArybB6
Gemini Pro Beginners: https://www.youtube.com/watch?v=mkFDhoQZC3U
Gemini Pro API: https://www.youtube.com/watch?v=V3vjwwIvB0I
Gemini Pro Vision API: https://www.youtube.com/watch?v=sI7VsMzDfms
Gemini Pro Function Calling: https://www.youtube.com/watch?v=iBxB_enzjks
Learn to Use Google Gemini/Bard: https://www.youtube.com/watch?v=FFclp3sfKEc
🔍 Timestamps:
0:00 - Introduction to Gemini API and Google AI Studio
0:33 - Service Accounts and Google Cloud Console Overview
1:19 - Using Vertex AI Python Package
1:29 - Generating API Keys in Google AI Studio
1:53 - Step-by-Step Coding Tutorial
3:00 - Comparing Google AI Studio and Vertex AI
3:47 - Advanced Application: Gemini Vision API
💡 Stay tuned till the end for a practical demonstration of integrating Gemini API into a Python application, including a unique example using the Gemini Vision API.
👍 If you find this tutorial helpful, please like, share, and subscribe for more AI-related content. Your support helps us create more informative and useful videos!
#GeminiAPI #Python #APIKEY #GoogleGemini #GoogleGeminiAI #Gemini #AI #GoogleB
Watch on YouTube ↗
(saves to browser)
Sign in to unlock AI tutor explanation · ⚡30
Playlist
Uploads from Mervin Praison · Mervin Praison · 0 of 60
← Previous
Next →
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Build GCP Infra using Pulumi in YAML format
Mervin Praison
How to Convert a Pulumi YAML File to Python Format
Mervin Praison
Speed Up AWS EKS: A Complete Guide to Performance Tuning & Debugging!
Mervin Praison
Learn GCP GKE to AWS EKS Migration in Just 5 Minutes: Quick Guide
Mervin Praison
AWS & Kubernetes: The Definitive Guide to Data Persistence with PV and PVC
Mervin Praison
ChatGPT Voice Conversation RELEASED! It's AMAZING!! (Demo)
Mervin Praison
How to Install Mistral 7B in Minutes: Quick & Easy Guide! ✅
Mervin Praison
Code Llama Install Locally: 🐍💻 Elevate Your Python Skills!
Mervin Praison
Orca Mini: Your Ultimate Guide to Install and Test on Mac & Linux 💻
Mervin Praison
Quick & Easy Vicuna Setup on Mac and Linux 💻
Mervin Praison
Quick Guide: Llama2 Local Installation and ChatGPT with pip! Python🛠️
Mervin Praison
Query PDFs Like a Pro with Local GPT: Full Setup Guide! 📜
Mervin Praison
LM Studio: EASIEST way to Run Large Language Models Locally!
Mervin Praison
AMAZING ChatGPT Vision is OUT! 🤯 14+ Examples (Step-by-Step) FULL Tutorial
Mervin Praison
Unbelievable! Build ANY App Instantly with Smol AI! 😲🔥
Mervin Praison
Amazing! AutoGen Made Easy: A Step-by-Step Beginners Guide 📚
Mervin Praison
How to Set Up LoLLMS and Run LLMs Locally! 🚀 Step-by-Step Tutorial
Mervin Praison
GPT4All: INSANE Way to Run Large Language Models Locally! 😲 Step-By-Step Tutorial
Mervin Praison
Incredible AI-Powered NPCs in Unity Game Engine: Step by Step Tutorial!🤯
Mervin Praison
MemGPT 🧠 LLM as Operating System. It's INSANE! Step-by-Step Tutorial 🤯
Mervin Praison
Text Generation Web UI: MIND-BLOWING Way to Run LLM Locally! 🤯
Mervin Praison
Unlock the INSANE Power of OpenAI GPT-4 with C#/.NET! 😲
Mervin Praison
Integrate Langchain and Ollama for Local AI Power 🤯 Indeed POWERFUL!
Mervin Praison
ChatDev: INSANE Virtual AI Agents! Future of Software Development 😲
Mervin Praison
Query PDFs Using Mistral: Unlock INSANE Power! 🤯
Mervin Praison
AutoGen + Open-Source LLMs: UNBELIEVABLE! Step-by-Step Tutorial You Can't Miss! 🤯
Mervin Praison
AutoGen + Text Generation WebUI: Unbelievable 100% Local Private Setup 🤯
Mervin Praison
MemGPT: Amazing! External Context for LLM #ai #llm #memgpt #generativeai #mem #gpt #openai #chatgpt
Mervin Praison
GeniA: Kubernetes + AI for MIND-BLOWING Operational Efficiency! 🤯 FULL Tutorial
Mervin Praison
VertexAI Meets LangChain for Mind-Blowing AI Conversations! 😲 Step by Step Tutorial
Mervin Praison
Simplified ChatGPT API Setup on Node.js for Newbies! 😍 Step by Step Tutorial
Mervin Praison
Autogen: Ollama integration 🤯 Step by Step Tutorial. Mind-blowing!
Mervin Praison
LiteLLM: One-Function Call to ANY Large Language Model! 🤯 UNBELIEVABLE!
Mervin Praison
ChatGPT Chatbot in Less Time Than You Think! 🚀😎 Step-by-Step Tutorial
Mervin Praison
LiteLLM Chatbot: Build Your Own in MINUTES! INSANE! 🤖🔥
Mervin Praison
Create Chatbot: Turn ANY Open-Source LLM into a Conversation Pro! 🤖
Mervin Praison
Create Chatbot: Ollama Integration Made UNBELIEVABLY Easy! 🎉
Mervin Praison
LlamaIndex + ChatGPT: Ingest Data and Experience UNBELIEVABLE Query Results! 🌟
Mervin Praison
INSANE! OpenAgents: Automated Data Analysis with Kaggle 🤯
Mervin Praison
React.js LLM Agent for Next-Gen Coding using ChatGPT 🚀 Mind-Blowing 🤯
Mervin Praison
MemGPT + Any LLM 🚀 100% Local & Private Integration Unveiled! Unlimited Memory
Mervin Praison
MemGPT + AutoGen 🧠🤖 Unlimited Memory & Autonomous AI Agents! INSANE🤯
Mervin Praison
AutoGen + Google's Palm LLM & More! Revolutionary AI Integration 🚀
Mervin Praison
MemGPT & LM Studio Integration Revealed! 🔥 Next-Level AI
Mervin Praison
🚀 AutoLLM: Unlock the Power of 100+ Language Models! Step-by-Step Tutorial
Mervin Praison
AutoLLM & Gradio Integration You Won't Believe! 🤯 Mind-Blowing
Mervin Praison
AutoLLM & FastAPI Tutorial: Query 100+ Language Models! 😱
Mervin Praison
Quivr: LLM's Second Brain - Transforming Data Management & Advanced Query with AI! 🤯
Mervin Praison
AutoGen & MemGPT with Local LLM: A Complete Setup Tutorial! 🧠 AMAZING 🤯
Mervin Praison
LocalAI: Free, Open Source OpenAI Alternative 🚀 INSANE 🤯 Step-by-Step Tutorial
Mervin Praison
Yarn Mistral 7B 128k LARGE context window, Small size 🤯 INSANE 🚀 Setup Tutorial!
Mervin Praison
Zephyr-7B: The Small and Mighty LLM 🤯 Step by Step Tutorial! 📘
Mervin Praison
Promptfoo: How to Test Your LLM ? 🚀 VERY EASY!
Mervin Praison
Pydantic: How to Validate LLM Responses? 🚀 Quality Response. VERY EASY!!!!
Mervin Praison
Pydantic: FORCE Your AI to Respond Back in UPPERCASE! 🤯 Step-by-Step Tutorial 🔥
Mervin Praison
Pydantic: How to use LLM to convert unstructured data to structured data?
Mervin Praison
AutoGen Function Calling: INSANE 🚀 Custom Integrations! Step-by-Step Tutorial 🤯
Mervin Praison
OpenAI Assistants API + Python 🤖 How to get started? (FULL Tutorial) 🤯 INSANE
Mervin Praison
GPT-4 Vision API 🤯 INSANE Video Recognition Powers! Step-by-Step Tutorial 🚀
Mervin Praison
GPT-4 Vision API 🚀 The Future of Image Recognition! 🤯 Step-by-Step Tutorial
Mervin Praison
More on: LLM Foundations
View skill →Related AI Lessons
Chapters (7)
Introduction to Gemini API and Google AI Studio
0:33
Service Accounts and Google Cloud Console Overview
1:19
Using Vertex AI Python Package
1:29
Generating API Keys in Google AI Studio
1:53
Step-by-Step Coding Tutorial
3:00
Comparing Google AI Studio and Vertex AI
3:47
Advanced Application: Gemini Vision API
🎓
Tutor Explanation
DeepCamp AI