Created
January 30, 2025 05:18
-
-
Save feliperyan/c23e1788b0e2ef19c3c8a024d658530c to your computer and use it in GitHub Desktop.
Minimal example to test service account private key and Vertex Gemini API
This file contains hidden or 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 vertexai | |
from vertexai.generative_models import GenerativeModel | |
# This will set an environment variable just for this script | |
os.environ['GOOGLE_APPLICATION_CREDENTIALS'] = "<your private key path>" | |
vertexai.init(project='<your_proj_id>', location='us-central1') | |
if __name__ == '__main__': | |
model = GenerativeModel('gemini-1.5-flash-002') | |
result = model.generate_content("write a haiku about cloud computing") | |
print(f'GEMINI RESULT:\n{result}') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment