Skip to content

Lab 1: Your first multimodal calls

Send a photo to an AI model, get structured data back, see what the image cost, and find where the model slips.

When Day 1, around 11:20 (10 minutes)
Format Trainer demo on the screen. Follow along on your laptop if you like.
Lab file labs/01-first-multimodal-calls.ts, run with npm run lab1
Files used data/whiteboard.png, data/invoice_01.png, data/chart_revenue.png

What you'll learn

  1. One model call can turn a messy photo into structured data, with no OCR step and no template.
  2. Images are paid for in tokens, and bigger images cost more.
  3. Models read printed numbers well, but estimating values off a chart is where they slip.

Step 0: Start the lab

Do: in your terminal, run npm run lab1 (all steps), or one step at a time with npm run lab1 -- 1, npm run lab1 -- 2 and so on. Keep labs/01-first-multimodal-calls.ts open in your editor so you can read each step's code.

You should see the banner first:

Provider: anthropic | model: claude-sonnet-5-5

(or your own provider and model).

Step 1: Turn a whiteboard photo into JSON

This is a slightly rotated, blurry photo of a team whiteboard:

The whiteboard photo used in Demo 1

Do: npm run lab1 -- 1. Step 1 prints the photo's path (Ctrl/Cmd + click to open it) and sends it to askJson(...).

You should see JSON along these lines (your wording will differ):

{
  "title": "Sprint 14 retro - claims OCR pilot",
  "action_items": [
    {"owner": "Rahul", "task": "Add table-detection step before extraction", "due": "Fri"},
    {"owner": "Priya", "task": "Build 50-doc gold set from Nov claims", "due": "next Wed"},
    {"owner": "Infra", "task": "Move PDFs to private bucket, no public links", "due": null}
  ],
  "decisions": ["Keep human review for claims > Rs 5 lakh"],
  "open_questions": ["Can we send scans to external API? (ask Legal)"],
  "dates_circled": ["Demo 12 Dec"]
}

Why it matters: the model read handwriting-style text on a tilted photo, understood which lines are tasks, decisions and questions, and even noticed the date inside the red circle.

Info

Discuss: what would this take with classic OCR plus rules? Which fields would you still check by hand before putting them into Jira?

Step 2: See what an image costs

Do: npm run lab1 -- 2. It sends the same invoice three times, at 400, 800 and 1240 pixels wide, then prints a usage table.

You should see a table like this (your numbers will differ by provider):

│ # │ model               │ sec │ in_tok │ out_tok │ images │ cached │
│ 1 │ 'claude-sonnet-5-5' │ 1.4 │ ...    │ 2       │ 1      │ false  │
│ 2 │ 'claude-sonnet-5-5' │ 1.6 │ ...    │ 2       │ 1      │ false  │
│ 3 │ 'claude-sonnet-5-5' │ 1.9 │ ...    │ 2       │ 1      │ false  │

Look at the in_tok column: it grows as the image gets bigger.

Why it matters: every image becomes tokens, and you pay for tokens. Rule of thumb: send the smallest image in which a person could still read the smallest text you need, and crop to the part you care about.

Step 3: Find where the model slips

Do: npm run lab1 -- 3. It asks four questions whose answers are known.

You should see four lines comparing the model's answer with the truth:

Probe Question Truth What usually happens
counting How many bars are in the chart? 6 Usually right
exact value The number printed above the Q3 FY26 bar 455 Usually right: it's printed
reading the line The AI-led share for Q4 FY26, read off the orange line 44 Sometimes off by a few points
spatial What's inside the red circle on the whiteboard? Demo 12 Dec Usually right

Why it matters: printed numbers are read reliably, but values estimated from a line or a bar's height are not. That's why Lab 2 always checks numbers with code.

Success

Checkpoint: you've seen a structured answer from a photo, watched token counts grow with image size, and found at least one probe worth double-checking.

Key takeaways

  • A single model call can read layout, handwriting-style text and diagrams together.
  • Image size is a cost and speed decision. Crop before you send.
  • Trust printed values more than estimated ones, and verify anything that matters.

Stuck?

  • Nothing happens for a long time: model calls take 2–15 seconds. If a step runs for more than a minute, press Ctrl + C and run it again.
  • ENOENT: no such file or directory, data/whiteboard.png: run the command from the main multimodal-ai-labs folder, not from inside labs.
  • The JSON looks different from the example: that's fine, as long as the owners, tasks and dates match the photo.