0
LLM Engineering & APIs
Phase 2Module 2 of 12

Gemini

Enterprises need model diversity beyond OpenAI — for cost optimization, vendor redundancy, and Google Cloud integration. Gemini provides native multimodality and competitive performance at lower price points.

If OpenAI is iOS, Gemini is Android — a capable alternative with different strengths, native integration with Google's ecosystem (Cloud, Search, Workspace), and competitive pricing.

Visual Workflows

Start here — study each diagram, then use + / to zoom if needed.

100%
Loading diagram...

Scroll inside the frame · use + / − to zoom

Key Takeaways

  • 1.Google Gemini is a family of multimodal LLMs natively trained on text, images, audio, and video — offering competitive alternatives to GPT-4 with strong integration into Google Cloud. Gemini family: Gemini 2.0 Flash (fast, cheap), Gemini 2.0 Pro (capable), Gemini 1.5 Pro (long context up to 2M tokens).
  • 2.Native multimodal: accepts text, images, audio, video in a single prompt. API via Google AI Studio (free tier) or Vertex AI (enterprise).
  • 3.SDK: google-generativeai Python package. Features: function calling, JSON mode, grounding with Google Search, code execution.
  • 4.Context caching for repeated long prompts. Safety settings configurable per request.

Real Example

Scenario

Analyzing a product demo video: send video file + prompt 'Summarize key features and identify UI issues' to Gemini 1.5 Pro. Model processes video natively (no frame extraction needed) and returns structured analysis.

What you would do

In LLM Engineering & APIs, apply Gemini to this scenario: Analyzing a product demo video: send video file + prompt 'Summarize key features and identify UI issues' to Gemini 1. Identify the inputs, run the technique, validate the output, and note one thing you would monitor in production.

Practice Task

Open the Code Walkthrough below and run it locally. Change one parameter related to Gemini (e.g. model, temperature, top_k, or tool name), observe the difference in output, and write 2–3 sentences explaining what changed.

Code Walkthrough

Highlighted lines show where Gemini happens in the code.

Gemini
1import google.generativeai as genai  # import dependencies2
3genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))  # key line for Gemini4model = genai.GenerativeModel("gemini-2.0-flash")  # key line for Gemini5
6# Text generation7response = model.generate_content("Explain RAG in 2 sentences.")  # key line for Gemini8print(response.text)  # show output for debugging9
10# Multimodal: image + text11import PIL.Image  # import dependencies12img = PIL.Image.open("diagram.png")13response = model.generate_content(["Describe this architecture diagram:", img])  # key line for Gemini14print(response.text)  # show output for debugging

Cheat Sheet

Quick recap

quick ref
  • genai.GenerativeModel('gemini-2.0-flash')
  • generate_content([text, image])
  • 1.5 Pro: 2M context window
  • AI Studio: free dev tier
  • Vertex AI: enterprise GCP
  • Context caching for long prompts

Common Mistakes

  • Using Vertex AI complexity when AI Studio suffices for prototyping
  • Not configuring safety settings — unexpected content blocks
  • Ignoring context caching for repeated large prompts — overpaying
  • Assuming Gemini API is identical to OpenAI — different SDK patterns