Skip to content

Latest commit

 

History

History

gemini

Google Gemini API code samples

Sep 2024 update: Updated code samples from Gemini 1.0 Pro (gemini-pro) and Pro Vision (gemini-pro-vision) models to Gemini 1.5 Flash (gemini-1.5-flash).

These are the code samples that are found in the blog post series introducing the Gemini API:

  1. A Better "Hello World!" sample
  2. Next steps beyond "Hello World!"
  3. Putting together a basic genAI web app
  4. (coming soon)

Links to each post down below in corresponding row for each code sample. Follow the appropriate instructions in each post to get these apps to run.

Code samples

Link App Description Platform Model Language
Post 1 gemtxt-simple-gai.py "Hello World!" Google AI Gemini 1.5 Flash Python 3
Post 1 gemtxt-simple-gai.js "Hello World!" Google AI Gemini 1.5 Flash Node.js (CommonJS)
Post 1 gemtxt-simple-gai.mjs "Hello World!" Google AI Gemini 1.5 Flash Node.js (modern JS/ECMAScript module)
Post 1 gemtxt-simple-gcp.py "Hello World!" GCP Vertex AI Gemini 1.5 Flash Python 3
Post 2 gemtxt-simple-gai.py Text API Google AI Gemini 1.5 Flash Python 3
Post 2 gemtxt-stream-gai.py Streaming Google AI Gemini 1.5 Flash Python 3
Post 2 gemtxt-simple-chat-gai.py Chat Google AI Gemini 1.5 Flash Python 3
Post 2 gemmmd-simple-loc-gai.py Multimodal (local image) Google AI Gemini 1.5 Flash Python 3
Post 2 gemmmd-simple-url-gai.py Multimodal (online image) Google AI Gemini 1.5 Flash Python 3
Post 2 gemmmd-simple-url-chat-gai.py Multimodal chat (online image) Google AI Gemini 1.5 Flash Python 3
Post 3 webgem Multimodal (uploaded image) Google AI Gemini 1.5 Flash Python & Node.js (CommonJS)