Chapter 01: Environment Setup
Install mise, bun, and get your OpenRouter API key. The foundation for everything.
TUTOR WITH THEFOCUS.AI
Copy this prompt into Claude, ChatGPT, or any external AI assistant. It points the assistant to the course instructions and links it to your student profile to track your progress and customize observations.
You are not enrolled yet. Enroll to generate a Student ID to track lesson completions and store learning notes.
Chapter 01: Environment Setup
What We’re Doing
We’re setting up a reproducible development environment using mise (a version manager), bun (a fast TypeScript runtime), and getting an API key for OpenRouter so we can talk to LLMs.
Step 1: Install mise
mise manages your development environment. It’s like asdf or nvm but faster and simpler.
Open a terminal and run:
curl https://mise.run | sh
You may need to restart your terminal afterward. Verify it’s working:
mise --version
Step 2: Install bun
With mise installed, getting bun is a single command:
mise use bun
This installs the latest version of bun and makes it available in your shell. Verify:
bun --version
Step 3: Get an OpenRouter API Key
OpenRouter is an API gateway that gives you access to hundreds of models through a single API key. Instead of managing separate keys for Anthropic, Google, and OpenAI, you have one key that routes to all of them.
- Go to openrouter.ai/settings/keys
- Create an account
- Add a credit card if required (you’ll spend maybe $1–5 for this entire tutorial)
- Create a new API key
Save the key in a .env file in your project directory:
echo 'OPENROUTER_API_KEY=sk-or-v1-your-key-here' > .env
Never commit .env to git. Make sure it’s in your .gitignore.
Step 4: Choose Your Model
Set the model you want to use:
echo 'AGENT_MODEL=google/gemini-3-pro-preview' >> .env
Alternative: if you prefer Claude, use anthropic/claude-opus-4.5.
As of this writing, Gemini 3 Pro Preview and Opus 4.5 work best for this tutorial. But feel free to experiment — one of the benefits of OpenRouter is that swapping models is just changing an environment variable.
Step 5: Create mise.toml
Create a mise.toml to lock in your tool versions:
[tools]
bun = "latest"
Step 6: Create a Project Directory
mkdir weekend-coding-agent
cd weekend-coding-agent
Copy your .env and mise.toml into this directory.
What We Have Now
weekend-coding-agent/
├── .env # OPENROUTER_API_KEY and AGENT_MODEL
├── .gitignore # includes .env
└── mise.toml # bun version locked
You’re ready to write your first agent. Let’s go.
The Source Files (for Reference)
The complete project structure is available at src/. Here’s what we’re building toward:
src/
├── index.ts # Entry point with REPL
├── agent.ts # Core agent loop (runTurn)
├── lib/
│ ├── api.ts # OpenRouter client, model stats
│ ├── logger.ts # JSONL session logging
│ ├── readline.ts # Terminal input handling
│ └── types.ts # Message, CompletionResponse interfaces
But we’ll build everything step by step. The agent will help.