Lesson 03 Ways to use AI
Theme:
Lesson 03 · Slide 1

Lesson 03 — Ways to use AI

Chat · API · CLI · Code & Agents — four doors into the same building.

AI for Dummies Module 3

The AI model doesn’t change. How you reach it does — and that choice changes everything about what you can accomplish.

By the end of this lesson you’ll know which door to open for any task — and why beginners should start at the front door and work outward.

Lesson 03 · Slide 2

Four doorways — one building

All four paths reach the same AI model. The door you pick determines who drives.

The AI Model (same brain) Claude / GPT / Gemini 💬 Chat Browser window You type → AI replies 🔌 API Code sends prompts Automated, at scale ⌨️ CLI Terminal commands Local / offline models 🤖 Agent AI reads & edits files Multi-step goals

Same expert. Same intelligence. The door you pick determines who drives: you by hand, your code automatically, a local tool privately, or an agent acting on your behalf.

Lesson 03 · Slide 3

The four doorways — click to explore

💬 Chat
No skill needed
🔌 API
A little coding
⌨️ CLI
Comfort with commands
🤖 Code / Agent
Technical comfort
Chat — A browser window where you type and the AI replies. Claude.ai, ChatGPT, Gemini. Zero setup, free tier available. Perfect for questions, writing, brainstorming, summaries. This is where everyone starts.
API — Your code sends the prompt instead of you. You get back a structured response you can process automatically. Use it when you need to do the same AI task hundreds or thousands of times — processing spreadsheets, building apps, automating pipelines.
CLI — The terminal: a text window where you type commands. Run ollama run llama3.2 and a local AI model opens right there — no browser, no internet after the download, fully private. Looks scary; it’s just typing.
Code / Agentic Tools — AI that doesn’t just answer, it acts. You say “fix this bug,” and it reads your files, writes the patch, runs the tests, reports back. Claude Code, Cursor, GitHub Copilot. Multi-step, real-file access.

☝ Click a card above to see details

Lesson 03 · Slide 4

Doorway 1 — Chat (the front door)

What Claude.ai looks like:

Claude.ai — New conversation
Summarize this email in 2 lines.
The email asks to reschedule Friday’s meeting to next Monday. No action needed until you reply.
Type a message…

What you can do right now:

  • Ask any question, get an explanation
  • Draft emails, reports, or social posts
  • Paste a document → instant summary
  • Debug a snippet of code
  • Brainstorm, translate, learn anything

The limit: one exchange at a time. Repeat the same thing 300 times? That’s the API’s job, not Chat’s.

Rule: Start here. Stay here until Chat can’t do what you need. Most people never need to leave.

Lesson 03 · Slide 5

Chat in action — a real 3-turn conversation

Watch how a follow-up message refines the answer without starting over.

You
Explain what DNS is in plain English. One paragraph, no jargon.
Claude

The Chat superpower: you refine, you don’t restart. “Shorter,” “more formal,” “add examples” — each follow-up builds on context the model already has.

Lesson 03 · Slide 6

Doorway 2 — the API (kitchen window)

API = Application Programming Interface. Instead of you typing, your code sends the message and handles the reply — automatically, in a loop, at any scale.

Chat = dining room. You sit down, the waiter takes one order, brings it back.

API = kitchen window. You slide structured tickets through. Thousands of tickets. Structured responses back. No waiter needed.

Same chef, same food — different doorway.

Your Code 💻 service window 🪟 AI Kitchen 🧠 prompt reply wrap in a loop → 10,000×
Lesson 03 · Slide 7

When you actually need the API

📊 You have 800 customer reviews and want a one-sentence sentiment tag on each.
Copy-pasting 800 times isn’t a plan. A 10-line Python script that loops over your spreadsheet: that’s the API.

🏗️ You’re building an app with an AI-powered feature.
The app calls the API on behalf of every user. That’s how every AI-powered product in the world is built.

⏰ You want AI to run on a schedule — every morning, process last night’s data automatically.
Script + scheduler + API = fully automated pipeline. No human clicking required.

Rule of thumb: if you’d need to type the same prompt more than a handful of times, the API removes all the repetition.

Lesson 03 · Slide 8

API in code — the canonical curl call

This is the actual Anthropic API call, straight from the documentation. Every library wraps exactly this.

💻Your code
→
🔑Key check
→
🧠AI model
→
📦Response
→
✅Your code uses it

Wrap this in a for loop → process your entire spreadsheet automatically.

curl https://api.anthropic.com/v1/messages \
  -H "x-api-key: $ANTHROPIC_API_KEY" \
  -H "anthropic-version: 2023-06-01" \
  -H "content-type: application/json" \
  -d '{
    "model": "claude-sonnet-4-6",
    "max_tokens": 1024,
    "messages": [{"role": "user", "content": "Explain what an API is in one sentence."}]
  }'
Lesson 03 · Slide 9

The Python equivalent — 7 lines

Install once, then call Claude from any Python script. This is a complete, working program.

# Install the library (one-time)
pip install anthropic
import anthropic

client = anthropic.Anthropic()
# reads ANTHROPIC_API_KEY from env

message = client.messages.create(
    model="claude-sonnet-4-6",
    max_tokens=1024,
    messages=[{
        "role": "user",
        "content": "Write a 2-line welcome email."
    }]
)

print(message.content[0].text)

What each part does:

  • Anthropic() — connects using your env key
  • model= — pick Haiku (cheap), Sonnet, or Opus
  • max_tokens — cap the length of the reply
  • messages= — the conversation so far
  • .content[0].text — the text of the reply

Wrap client.messages.create() in a for row in csv: loop and you’ve just automated your entire spreadsheet.

Lesson 03 · Slide 10

The API key — your password and credit card

An API key is a long secret string. Every call made with it is billed to your account — even if someone else makes the call.

🚫 Never do this

  • Paste it into a chat window
  • Hardcode it directly in your script
  • Commit it to a GitHub repo
  • Share it in a message or email
  • Leave it in a screenshot

✅ Always do this

  • Store it in an environment variable
  • Set a monthly spending cap immediately
  • Use a separate key per project
  • Rotate it the moment you suspect a leak
  • In code: os.environ["ANTHROPIC_API_KEY"]

Leaked keys are used by strangers and run up real bills. It happens to beginners constantly — paste key into tutorial, push to GitHub, get charged $300. Set the spending limit first. It’s the one safety net that stops the damage.

Lesson 03 · Slide 11

Doorway 3 — CLI (the terminal)

The terminal is a text window where you type commands. It looks scary. It’s just… typing.

$ ollama run llama3.2
pulling manifest… done
>>>
What is the capital of France?
The capital of France is Paris. It has
been the country’s capital since 987 AD.
>>>
/bye

That’s a real CLI session. Fully offline, zero cost after download, 100% private.

CLI is great for: local AI tools (Ollama, LM Studio CLI), running scripts, servers with no GUI, developer automation workflows.

Useful Ollama commands:

ollama list          # installed models
ollama pull mistral  # download model
ollama serve         # run as a server

Gentle CLI intro comes in Lesson 04 when we install Ollama. You don’t need to touch it today.

Lesson 03 · Slide 12

Doorway 4 — Agents (AI that acts)

Chat answers. An agent executes. Give it a goal and step through how it works.

Your instruction: “Fix the bug in auth.py and make sure the tests still pass.”

📖
Step 1 — Reads the file
Scanning auth.py (247 lines)…
🔍
Step 2 — Identifies the bug
Line 89: token expiry not checked on refresh path
✏️
Step 3 — Writes the fix
Adding expiry check, updating return value
▶️
Step 4 — Runs the test suite
✓ All 14 tests pass
📋
Step 5 — Reports back to you
“Fixed. Refresh path now checks token expiry. All tests pass. Want me to update the docs too?”
Lesson 03 · Slide 13

Agent vs Chat — the structural difference

CHAT — you steer every step

You type a prompt "Explain X" Claude replies "Here’s an explanation…" You decide what to do next. Every step needs you.

AGENT — you set the goal

You give a goal "Fix the bug in auth.py" 📄 Read files ✎ Write fix ▶ Run tests ✓ Report: “Done, tests pass” You review and approve.

Key difference: Chat gives you advice. An agent takes action. That power comes with a responsibility: always review what the agent proposes before it changes real files.

Lesson 03 · Slide 14

Agent example — Claude Code session

Claude Code is Anthropic’s coding agent. It runs in your terminal, reads your project, and edits files. Here’s what a session looks like:

# Inside your project folder:
$ claude
✔ Connected to Claude (claude-sonnet-4-6)
❯ Rename all Python variables called tmp to temp_buffer in the project.
🔍 Scanning project… found 6 files with tmp
📋 Proposed changes:
+ utils.py line 14: temp_buffer = []
+ parser.py line 88: temp_buffer = data
… 4 more changes
❯ Looks good, apply all changes.
✔ Applied 6 changes across 6 files. No tests broken.

You need: a paid Claude plan or API key. Install: npm install -g @anthropic-ai/claude-code or curl -fsSL https://claude.ai/install.sh | bash

Safety rule: always run Claude Code on version-controlled code. Read what it proposes before approving. It can and will change real files.

Lesson 03 · Slide 15

All four doorways compared

Doorway Skill needed Install? Best for Cost Privacy
💬 Chat None No Questions, writing, learning Free tier Cloud
🔌 API A little coding pip install Automation, apps, batches Per token Cloud
⌨️ CLI Typing commands Yes (Ollama) Local tools, scripts, servers Free Local
🤖 Agent Tech-comfortable Yes Coding, multi-step file tasks Per token Cloud

Pick the doorway by what you need, not by what sounds most impressive. Chat solves roughly 80% of everyday problems and needs zero setup.

Lesson 03 · Slide 16

Cloud vs local — cost at scale

Cloud API costs money per token. Local models (Ollama) are free per call after setup. Here’s what 10,000 short calls looks like:

Claude Haiku (cloud)
~$0.75
Claude Sonnet (cloud)
~$3.00
Claude Opus (cloud)
~$15.00
Local (Ollama / LM Studio)
$0.00

~50 input + 50 output tokens per call. Prices illustrative — check provider docs for current rates.

Cloud: best quality, easiest setup, pay per use. Data leaves your machine. Ideal for most tasks.

Local: free per call, fully private, works offline. Needs decent hardware (16 GB RAM recommended). Perfect for sensitive data or high volume.

Lesson 03 · Slide 17

The beginner path — start at Chat, branch when needed

💬 Start in Chat Week 1 – 2 (or longer) Can Chat do it? Yes No Need it 500× ? → API Edit real files ? → Agent Need privacy ? → CLI No prize for using a fancier door than you need.

Week 1–2: Chat only. Use Claude.ai for real daily tasks. Learn how to ask well, how to follow up, and when to verify answers.

🔁 “I need this 500 times”
→ Move to API

📂 “I want it to edit my files”
→ Move to Code / Agents

🔒 “I need total privacy / offline”
→ Install Ollama & use the CLI

Lesson 03 · Slide 18

Lesson 03 — key takeaways

The expert in the building is the same regardless of which door you use. Pick based on what you need to do — not what sounds most technical.

🧪 This week’s action: open Claude.ai and use it for three real tasks you’d normally do yourself. Notice where it shines, where it needs guidance, where it gets things wrong.

Read Theory → Go to Homework →
1 / ?