Last active
May 5, 2024 03:33
-
-
Save wilderlopes/e7f126e41d5363cb6e77b959cee7acfa to your computer and use it in GitHub Desktop.
Hello World for Google Gemini Pro
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import google.generativeai as genai | |
# GOOGLE API KEY | |
# 1. Create one at https://aistudio.google.com/app/apikey | |
# 2. In your terminal, do `export GOOGLE_API_KEY = 'YOUR_KEY'` | |
GOOGLE_API_KEY = os.getenv('GOOGLE_API_KEY') | |
# List all models available | |
for m in genai.list_models(): | |
if 'generateContent' in m.supported_generation_methods: | |
print(m.name) | |
# Example using `gemini-pro` | |
model = genai.GenerativeModel('gemini-pro') | |
response = model.generate_content("") | |
print(response.text) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment