From Zero to Gen AI Hero with Gemini

Get the Code: Google Colab
If there is one thing I’ve learned working with founders, it’s that the gap between having an AI idea and shipping it can feel massive. You have to navigate new libraries, choose between dozens of models, and worry about infrastructure.
In this Startup School session, I wanted to strip away that complexity. Our goal for Week 1 of the Q1'25 series was simple: Get your first Generative AI prototype running in under an hour.
In this post, I’ll recap the key takeaways from the video and walk you through the Python notebook so you can start building today.
Why Vertex AI?
For early-stage startups, the platform decision often comes down to speed vs. scale.
- Speed: You want to test ideas in a notebook immediately.
- Scale: You need an API that won’t crash when you go viral.
We chose Vertex AI for this course because it solves both. It gives you a unified API to access Google’s most capable models—like Gemini 1.5 Pro and Flash—with enterprise-grade security and reliability built-in.
Code Walkthrough: The “Hello World” of Gen AI
The accompanying notebook serves as a starter kit. Here is a breakdown of the essential code blocks we covered in the session, updated to use the latest unified google-genai SDK.
1. Setup and Authentication
First, install the library:
pip install google-genai
Then, initialize your connection. This SDK works for both Google AI Studio (API Key) and Vertex AI (Cloud Project).
from google import genai
from google.genai import types
import os
# To use Vertex AI (Recommended for production/scale)
# Ensure you have authenticated with `gcloud auth application-default login`
client = genai.Client(
vertexai=True,
project="your-project-id",
location="us-central1"
)
# OR to use Google AI Studio (Great for prototyping)
# client = genai.Client(api_key=os.environ["GEMINI_API_KEY"])
2. Calling the Model
We are using Gemini 2.0 Flash (or gemini-2.0-flash-001), which offers an incredible balance of low latency and reasoning capability.
response = client.models.generate_content(
model="gemini-2.0-flash-001",
contents="What's the largest planet in our solar system? Tell me 3 facts about it."
)
print(response.text)
Pro Tip: You can easily customize the behavior using config:
response = client.models.generate_content(
model="gemini-2.0-flash-001",
contents="Tell me 3 facts about Jupiter.",
config=types.GenerateContentConfig(
temperature=0.7, # Controls randomness
system_instruction="Speak like a pirate."
)
)
3. Structured Output (JSON) & Pydantic
One of the biggest pain points in LLM development is parsing the response. With the unified SDK, you can pass a Pydantic model directly to schema-enforce the output.
from pydantic import BaseModel
class Planet(BaseModel):
name: str
moons: int
is_gas_giant: bool
class SolarSystem(BaseModel):
planets: list[Planet]
response = client.models.generate_content(
model="gemini-2.0-flash-001",
contents="List the planets in the solar system.",
config=types.GenerateContentConfig(
response_mime_type="application/json",
response_schema=SolarSystem
)
)
# The response is automatically parsed into your object!
solar_system = response.parsed
for planet in solar_system.planets:
print(f"{planet.name} has {planet.moons} moons.")
4. Function Calling (Tool Use)
Gemini can “act” by calling functions you provide. This is essential for building agents.
def get_current_weather(location: str):
"""Returns the weather for a given location."""
# In a real app, call a weather API here
return "sunny"
response = client.models.generate_content(
model="gemini-2.0-flash-001",
contents="What is the weather in Boston?",
config=types.GenerateContentConfig(
tools=[get_current_weather] # Pass the function directly
)
)
# The model will return a specific 'function call' part
print(response.function_calls)
5. Multimodality (Looking at Images/PDFs)
Gemini can natively understand documents and images without external OCR tools.
import requests
# Download a PDF
pdf_url = "https://arxiv.org/pdf/1706.03762"
pdf_content = requests.get(pdf_url).content
response = client.models.generate_content(
model="gemini-2.0-flash-001",
contents=[
types.Part.from_bytes(data=pdf_content, mime_type="application/pdf"),
"Summarize this paper in 2 sentences."
]
)
print(response.text)
Key Takeaways for Founders
- Uniformity: The new
google-genaiSDK lets you switch between AI Studio and Vertex AI with a single parameter change. - Reliability: Use Structured Output for anything programmatic. Don’t rely on regex to parse JSON from Markdown blocks.
- Multimodality: Don’t just stick to text. Sending a PDF or image is often cheaper and faster than extracting the text yourself.
What’s Next?
This session laid the foundation. In the coming weeks of Startup School, other colleagues will help you take this further by connecting these models to your own data (RAG) and building autonomous agents.
Ready to build? Clone the notebook, swap in your Project ID, and run your first cell!