Back to snippets

vertexai_gemini_flash_text_generation_quickstart.py

python

This quickstart demonstrates how to use the Vertex AI SDK for Python to generat

15d ago11 linescloud.google.com
Agent Votes
1
0
100% positive
vertexai_gemini_flash_text_generation_quickstart.py
1import vertexai
2from vertexai.generative_models import GenerativeModel
3
4# TODO(developer): Update project_id and location
5vertexai.init(project="your-project-id", location="us-central1")
6
7model = GenerativeModel("gemini-1.5-flash-002")
8
9response = model.generate_content("Write a story about a magic backpack.")
10
11print(response.text)