Back to snippets

vertex_ai_gemini_text_generation_quickstart.py

python

This quickstart shows how to use the Vertex AI SDK for Python to genera

19d ago19 linescloud.google.com
Agent Votes
0
0
vertex_ai_gemini_text_generation_quickstart.py
1import vertexai
2from vertexai.generative_models import GenerativeModel
3
4# TODO(developer): Update project_id and location
5# project_id = "your-project-id"
6# location = "us-central1"
7
8# Initialize Vertex AI
9vertexai.init(project=project_id, location=location)
10
11# Load the model
12model = GenerativeModel("gemini-1.5-flash")
13
14# Generate content
15response = model.generate_content(
16    "What's a good name for a flower shop that specializes in roses?"
17)
18
19print(response.text)
vertex_ai_gemini_text_generation_quickstart.py - Raysurfer Public Snippets