Day 5 of 5
⏱ ~60 minutes
Google Cloud in 5 Days — Day 5

AI APIs and Vertex AI

Use Vision API, Natural Language API, and call Gemini via the Vertex AI SDK to process and analyze data.

Pre-built AI APIs

GCP offers AI APIs that require zero ML knowledge — just HTTP calls. They're trained by Google and ready to use.

Terminal
pip install google-cloud-vision google-cloud-language google-cloud-aiplatform
Vision API
from 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)
Gemini via Vertex AI
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)
ℹ️
Vertex AI is GCP's unified ML platform. It hosts both Google's models (Gemini, Imagen) and lets you deploy your own. For most applications, the pre-built Gemini models via Vertex AI are all you need.
📝 Day 5 Exercise
Build an AI Data Pipeline
  1. U
  2. s
  3. e
  4. t
  5. h
  6. e
  7. V
  8. i
  9. s
  10. i
  11. o
  12. n
  13. A
  14. P
  15. I
  16. t
  17. o
  18. e
  19. x
  20. t
  21. r
  22. a
  23. c
  24. t
  25. t
  26. e
  27. x
  28. t
  29. f
  30. r
  31. o
  32. m
  33. 3
  34. i
  35. m
  36. a
  37. g
  38. e
  39. s
  40. (
  41. o
  42. r
  43. u
  44. s
  45. e
  46. t
  47. h
  48. e
  49. N
  50. a
  51. t
  52. u
  53. r
  54. a
  55. l
  56. L
  57. a
  58. n
  59. g
  60. u
  61. a
  62. g
  63. e
  64. A
  65. P
  66. I
  67. t
  68. o
  69. a
  70. n
  71. a
  72. l
  73. y
  74. z
  75. e
  76. s
  77. e
  78. n
  79. t
  80. i
  81. m
  82. e
  83. n
  84. t
  85. i
  86. n
  87. a
  88. l
  89. i
  90. s
  91. t
  92. o
  93. f
  94. r
  95. e
  96. v
  97. i
  98. e
  99. w
  100. s
  101. )
  102. .
  103. F
  104. e
  105. e
  106. d
  107. t
  108. h
  109. e
  110. r
  111. e
  112. s
  113. u
  114. l
  115. t
  116. s
  117. i
  118. n
  119. t
  120. o
  121. B
  122. i
  123. g
  124. Q
  125. u
  126. e
  127. r
  128. y
  129. .
  130. W
  131. r
  132. i
  133. t
  134. e
  135. a
  136. q
  137. u
  138. e
  139. r
  140. y
  141. t
  142. o
  143. s
  144. u
  145. m
  146. m
  147. a
  148. r
  149. i
  150. z
  151. e
  152. t
  153. h
  154. e
  155. f
  156. i
  157. n
  158. d
  159. i
  160. n
  161. g
  162. s
  163. .

Day 5 Summary

  • Vision API: labels, text (OCR), faces, objects — all from a single image upload.
  • Natural Language API: sentiment, entities, syntax — for text analysis without training a model.
  • Vertex AI hosts Gemini. The Python SDK mirrors the Gemini API syntax.
  • Pre-built APIs cost per call but require zero training data or ML expertise.
Finished this lesson?