Gemini API quickstart (in Python)

Hey folks! I just got done hacking on a project to make a simple Gemini API quickstart using Python and Flask. It comes with a backend, JS/HTML frontend, and support multi-modal image uploads:

Enjoy!

7 Likes

A Note to Europeans:

You may be unable to generate an API key for the Gemini API due to regional restrictions, but you can still access the models through the Vertex AI platform, this does however require a few changes to the code to align with the migration guide provided by Google.

You fortunately don’t have to deal with this, as I have already done the work for you:

To enable the Vertex AI API for this project, follow these step’s.

  1. head over to console.cloud.google.com and create a new project called “Gemini API Quickstart”
  2. Go to console.cloud.google.com/vertex-ai and enable the Vertex API.
  3. follow this tutorial to set up your credentials locally (or just use the command gcloud auth application-default login) and set your project using the command gcloud config set project "gemini-api-quickstart"

Have Fun! :heart:

2 Likes