Week 2: Installing & First Run¶
What you'll learn:
- LLM providers (Anthropic, OpenAI, Ollama)
- API keys vs. subscriptions
- The OpenCode TUI and keyboard shortcuts
- The /init command and AGENTS.md
- Your first real task: fix a typo
What is an LLM Provider?¶
A company (or service) that runs a language model and gives you access to it.
OpenCode is provider-agnostic — works with multiple providers.
Three main options: 1. Anthropic (Claude) 2. OpenAI (GPT) 3. Local Ollama (offline, free)
Option 1: Anthropic (Claude)¶
What: Claude family of LLMs (Opus, Sonnet, Haiku)
Access: API key or Claude.ai subscription
Cost: Pay-as-you-go (~$0.003 per 1K input tokens with Sonnet)
Best for: Learning. Excels at coding. Default for this course.
Sign up: console.anthropic.com
Option 2: OpenAI (GPT)¶
What: GPT-4, GPT-4o, GPT-3.5-turbo
Access: API key or ChatGPT Plus subscription
Cost: Pay-as-you-go (~$0.005 per 1K input tokens for GPT-4o)
Best for: If you already have an OpenAI account.
Trade-off: More expensive, but widely adopted.
Sign up: platform.openai.com
Option 3: Local Ollama¶
What: LLM server runs on your machine
Access: Free, no API key needed
Cost: Zero (after download)
Best for: Offline work, privacy, no budget
Trade-off: Models less capable than cloud APIs. Okay for Weeks 1–3.
Download: ollama.ai
API Keys vs. Subscriptions¶
| Aspect | API Key | Subscription |
|---|---|---|
| How | Secret token + pay per request | Monthly flat fee |
| For | OpenCode + integrations | Web chat only (Claude.ai, ChatGPT) |
| Cost | $5–30/month if careful | $20/month flat |
| For this course | Use API key | Don't use subscription |
Why API key? Granular control, cost transparency, works with OpenCode.
The OpenCode TUI¶
What: Terminal interface for conversation + file editing + commands
Layout:
- Top: Message history
- Bottom: Input box
- Right: Mode switcher [plan | build]
Key shortcuts:
- Enter — Send prompt
- Tab — Switch modes
- Ctrl+C — Interrupt
- Ctrl+L — Clear screen
The Two Modes¶
Plan Mode¶
- Read-only
- Can investigate, ask questions
- No approval prompts
- Safe to explore
Build Mode¶
- Full access (read, edit, run bash)
- Will ask approval for dangerous ops
- Use after planning
- For making changes
Workflow: Plan first → Build second
The /init Command¶
What: Analyzes your project and generates AGENTS.md
What AGENTS.md contains: - Project type (Node.js? Python? Rust?) - Key directories (src/, tests/, docs/) - Code style conventions (Prettier? ESLint?) - What NOT to do (boundaries)
Why: Agent knows your project without you describing it every time
How to use it: Type init in OpenCode input, press Enter
What AGENTS.md Looks Like¶
# Project Conventions for [Project Name]
## Context
This is a Node.js application for [purpose].
## Key Directories
- `src/` — Source code
- `tests/` — Test files (Jest)
## Conventions
- Code style: ESLint + Prettier
- Testing: Jest (npm test)
## Out of Bounds
- Do not modify package.json
- Do not run npm install without asking
After /init runs: Read it aloud. Did the agent understand your project?
Your First Task¶
Scenario: Fix a typo in src/index.js
- Wrong: consoel.log()
- Right: console.log()
Steps:
1. Install OpenCode
2. Get API key (Anthropic or OpenAI)
3. Set ANTHROPIC_API_KEY env var
4. Run opencode
5. Ask agent to find the typo (plan mode)
6. Ask agent to fix it (build mode)
7. Verify: grep console.log src/index.js
Cost & Budget¶
For this 10-week course: - Weeks 1–3: ~$2–3 - Weeks 4–6: ~$5–10 - Weeks 7–10: ~$10–20 - Total: ~$20–30
Model choice matters: - Sonnet (Anthropic): Cheaper, good enough - GPT-4o (OpenAI): More expensive, faster - Ollama: Free, less capable
Pro tip: You can swap providers mid-course.
Common Questions¶
Q: Can I use OpenCode without an API key? A: Yes, with Ollama (local, free). Less capable but works.
Q: Do I pay for every keystroke? A: No. Only when you press Enter and send a prompt.
Q: What if I'm offline? A: Use Ollama. Download a model on another machine, then serve it locally.
Q: Can I switch providers later?
A: Yes. Just change the env var (ANTHROPIC_API_KEY ↔ OPENAI_API_KEY).
Week 2 Labs¶
Lab 2.1: Install OpenCode + provider key. Fix a typo end-to-end.
Lab 2.2: Run /init on a real open-source project. Read AGENTS.md aloud.
Reflection: When did the agent get it wrong? Why?
Next Week: Plan vs. Build¶
In Week 3, you'll learn to use plan mode deeply: - How to explore codebases safely - When to stay in plan mode (code review, audits) - How to write better prompts for exploration
For now: Install. Get a key. Run your first task.