Use Vision API, Natural Language API, and call Gemini via the Vertex AI SDK to process and analyze data.
GCP offers AI APIs that require zero ML knowledge — just HTTP calls. They're trained by Google and ready to use.
pip install google-cloud-vision google-cloud-language google-cloud-aiplatformfrom google.cloud import vision
client = vision.ImageAnnotatorClient()
with open('photo.jpg', 'rb') as f:
content = f.read()
image = vision.Image(content=content)
# Detect labels
response = client.label_detection(image=image)
for label in response.label_annotations:
print(f'{label.description}: {label.score:.2f}')
# Read text from image
response = client.text_detection(image=image)
print(response.text_annotations[0].description)import vertexai
from vertexai.generative_models import GenerativeModel
vertexai.init(project='YOUR_PROJECT_ID', location='us-central1')
model = GenerativeModel('gemini-1.5-flash')
response = model.generate_content(
'Explain cloud computing in one paragraph for a beginner.'
)
print(response.text)
# With a system prompt
model = GenerativeModel(
'gemini-1.5-flash',
system_instruction='You are a concise technical writer. Always use bullet points.'
)
response = model.generate_content('What is Kubernetes?')
print(response.text)