AI Tools

How to Access and Use Gemini 1.5 Pro API Right Now

Google not too long ago concluded its Cloud Subsequent 2024 occasion the place the search large made Gemini 1.5 Professional obtainable to all customers, as a part of a public preview. And with that, it additionally opened API entry to the Gemini 1.5 Professional mannequin for all customers. Earlier, Google launched API entry for Gemini 1.0 Professional however builders have been ready for this highly-promising mannequin. Presently, the API is free to make use of and can stay so till Could 1, 2024. So if you wish to entry and use the Gemini 1.5 Professional API key to guage the mannequin, comply with our information beneath.

Get API Key For Gemini 1.5 Professional

  • Head over to aistudio.google.com/app/apikey (visit) and sign up along with your Google account.
  • Click on on “Create API key” and choose one of many initiatives.
  • Now, click on on “Create API key in present venture“.
select project in google ai studio
  • And there you go! The Gemini 1.5 Professional API key can be generated instantly. Copy and retailer it securely.
gemini 1.5 pro api key generated

Use Gemini 1.5 Professional API Key

I’m going to point out some examples in Python on the right way to use the Gemini 1.5 Professional API key for each textual content and picture examples. Listed below are the steps to comply with.

  • To begin with, be sure you have put in Python together with Pip in your laptop.
  • After that, fireplace up the Terminal and run the beneath instructions to put in Gemini’s dependencies and Pillow to deal with photos.
pip set up -q -U google-generativeai
pip set up Pillow

install google generative ai dependency
  • After you have executed that, open a code editor of your selection like Notepad++ or Elegant. You too can open Visible Studio Code for a greater IDE atmosphere.
  • Subsequent, copy and paste the beneath code into your code editor.
import google.generativeai as genai

genai.configure(api_key='XXXXXXXXXXXXXXXXXXXX')

mannequin = genai.GenerativeModel('gemini-1.5-pro-latest')

response = mannequin.generate_content("clarify moore's regulation like I'm 5")

print(response.textual content)
  • Right here, I’ve outlined the mannequin as gemini-1.5-pro-latest and used my very own API key. Within the subsequent line, you’ll be able to set your query.
sample code to test gemini 1.5 pro api
  • Now, save the file with .py extension and run the file in your Terminal. As you’ll be able to see, the Gemini 1.5 Professional correctly explains the idea similar to I requested it to do.
gemini 1.5 pro api explaining concept in terminal
  • Since Gemini 1.5 Professional is a multimodal mannequin, you may as well cross a picture with the beneath code to test its imaginative and prescient functionality.
import google.generativeai as genai
import PIL.Picture

img = PIL.Picture.open("picture.png")

genai.configure(api_key='XXXXXXXXXXXXXXXXXXX')

mannequin = genai.GenerativeModel('gemini-1.5-pro-latest')

response = mannequin.generate_content(["what do you see in this image", img])

print(response.textual content)
  • Right here, I’m pointing to a neighborhood “picture.png” file which is in the identical listing because the Python file, and asking the query beneath. gemini-1.5-pro-latest helps textual content and picture enter in a single single mannequin.
  • Now, merely run the code, and voila! It would analyze the picture and output the outcome. I discovered it fairly correct when coping with photos.
gemini 1.5 pro api analyzing image and outputing in terminal

Effectively, that’s how one can entry the API key for Gemini 1.5 Professional and take a look at it with Python. By the best way, Google has not revealed detailed documentation for the Gemini 1.5 Professional mannequin. When Google updates its assets, we’ll add extra coding examples on this article. Anyway, that’s all from us. If you’re dealing with any points, tell us within the remark part beneath.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Back to top button