Lesson 16 Google Gemini
Theme:

Homework

Three tasks exploring cross-provider comparison, Gemini’s multimodal strengths, and LLM cost analysis.

Complete all three lab exercises before starting the homework. These tasks build on the SDK skills and comparison patterns from the lab.

📥 Reference Solution

⬇ lab_answer.pdf

Task 1 — Three-Way Model Showdown

Objective

Systematically compare Gemini, Claude, and GPT on the same set of prompts to understand each provider’s strengths.

Instructions

  1. Design 10 diverse test prompts covering: coding, creative writing, factual Q&A, reasoning, summarisation, multilingual, math, instruction following, structured output (JSON), and conversational tone
  2. Send each prompt to all three models: gemini-2.5-flash, claude-sonnet-4-20250514, and gpt-4o
  3. For each response, record: response text, token count, response time, and your quality rating (1–5)
  4. Build a summary table showing which model won each category and the overall score
  5. Write a short analysis (200–300 words) explaining the patterns you observed — which types of tasks favour which model and why
Tip: If you lack an OpenAI key, run a two-way comparison (Gemini vs Claude) and note where you predict GPT would differ based on the theory reading.

Deliverable

A notebook with all 10 prompts, responses from each model, a comparison table, and written analysis.

Self-check: At least 10 prompts tested across all available providers. Summary table clearly shows per-category winners. Analysis explains observed patterns with specific examples.

Task 2 — Gemini Multimodal Explorer

Objective

Explore Gemini’s unique multimodal capabilities by building a mini-application that processes images and (optionally) audio or video.

Instructions

  1. Collect 5 diverse images: a photograph, a chart/graph, a document scan, a screenshot of code, and an infographic or diagram
  2. For each image, send three different analysis prompts to Gemini:
    • A general description prompt ("Describe this image in detail.")
    • A task-specific prompt (e.g., "Extract all text from this document" or "Explain the trend shown in this chart")
    • A creative prompt (e.g., "Write a short story inspired by this image")
  3. Record the token cost of each image input using usage_metadata
  4. For at least 2 images, compare the same analysis task between Gemini and Claude’s vision to note quality differences
  5. Bonus: If you have a short video or audio file, use Gemini’s upload_file() to analyse it — this is a capability unique to Gemini among major providers:
    video = genai.upload_file("clip.mp4")
    response = model.generate_content([
        "Summarise what happens in this video.",
        video,
    ])
    print(response.text)

Deliverable

A notebook processing 5 images with 3 prompts each (15 total calls), token costs logged, and at least 2 cross-provider vision comparisons.

Self-check: All 5 images processed successfully. Token costs documented for each. Cross-provider comparison includes specific quality observations, not just “both were good.”

Task 3 — LLM Cost Analysis Calculator

Objective

Build a cost comparison calculator that estimates monthly spend across Gemini, Claude, and GPT for a realistic application scenario.

Instructions

  1. Define a realistic application scenario (e.g., a customer support chatbot handling 1,000 conversations per day, averaging 4 turns each, with ~500 input tokens and ~300 output tokens per turn)
  2. Use current pricing to calculate monthly costs for each provider. Reference pricing:
    ModelInput (per MTok)Output (per MTok)
    Gemini 2.5 Flash$0.15–$0.60$0.60–$3.50
    Gemini 2.5 Pro$1.25–$10$10–$30
    Claude Sonnet$3$15
    Claude Haiku$0.25$1.25
    GPT-4o$2.50$10
    GPT-4o mini$0.15$0.60
  3. Write a Python function that takes daily_conversations, turns_per_conversation, avg_input_tokens, and avg_output_tokens as parameters and outputs a cost comparison table
  4. Run the calculator for three scenarios: low volume (100 conversations/day), medium (1,000/day), and high (10,000/day)
  5. Include a brief recommendation (100–200 words) on which model you would choose for each scenario and why, considering both cost and quality trade-offs

Deliverable

A notebook with the cost calculator function, three scenario analyses, and a written recommendation for each.

Self-check: Calculator produces correct monthly costs for all models across all three scenarios. Recommendations consider quality vs cost trade-offs, not just cheapest option.

Submission Checklist