Basic Agents / Lesson 4

Setting Up Your First Agent

Pick a harness, get an API key, configure your model, give it a tool, and watch it complete a task. Should take under 30 minutes.

Goal

Have a working agent you can delegate simple tasks to, installed and running on your machine

What You'll Need

⏱ Time: 25 minutes  |  📋 Tasks:

  • A computer with internet access
  • An email address to create an API account
  • A credit card (most API providers require one, even for free tiers)
  • Lessons 1-3 of this track (understand what you're installing)

Why Most First Attempts Fail

The most common mistake people make setting up their first agent is trying to configure everything at once. They install a harness, create accounts at three model providers, set up a vector database, configure custom tools, and then wonder why nothing works.

The right approach is the opposite: start minimal. One harness. One model. One tool. Get that working. Then expand.

Step 1: Pick Your Harness

Based on Lesson 2, choose one harness to start with. For your first agent, I recommend either:

  • Opencode Desktop — if you want a visual interface and easy setup. Download from opencode.ai, install it like any application.
  • Opencode CLI — if you're comfortable in a terminal. Install via npm install -g @opencode/cli.
  • Claude Desktop — if you already use Claude. Download from anthropic.com, install, and enable Cowork mode.

Don't agonize over this choice. You can switch later. Pick the one that makes you most likely to actually try it today.

Step 2: Get an API Key

Your harness needs a model to work with. That means getting an API key from a model provider.

Choose Your Provider

For a first agent, you want something cheap and reliable. These are good starting points:

  • OpenAI — Go to platform.openai.com, sign up, navigate to API keys, create a new key. Add $5-10 in credits. GPT-4o-mini is cheap and capable enough for your first experiments.
  • Anthropic — Go to console.anthropic.com, sign up, create an API key. Claude Sonnet is a great mid-tier model for agent work.
  • Openrouter — A single API key that gives you access to many models. Good for experimenting with different providers without creating multiple accounts.

Security Rule

Treat your API key like a password. Never commit it to git, never paste it in a forum, never share it. The harness will store it locally. If you suspect it's leaked, revoke it immediately and create a new one.

Step 3: Configure and Connect

Once you have a harness installed and an API key, you need to tell the harness where to find the model.

In Opencode Desktop: Open Settings > Models > Add Provider. Paste your API key, select your model (e.g. GPT-4o-mini), and save. The harness will test the connection automatically.

In Opencode CLI: Run opencode config set OPENAI_API_KEY sk-... or set the OPENAI_API_KEY environment variable. Then run opencode in any directory to start a session.

In Claude Desktop: Go to Settings > Developer > API Keys. Paste your key. Claude's built-in model is already configured — you just need to enable it for agent use.

After connecting, run a quick test: ask the agent a simple question. "What directory am I in?" or "List the files in this folder." If it answers correctly, your setup works.

Step 4: Give It a Tool

A connected agent can chat. An agent with a tool can work. For your first tool, add file system access.

  • Opencode Desktop — File access is enabled by default. The agent can read and write files in directories you specify.
  • Opencode CLI — Same. The agent works in the directory you launched it from.
  • Claude Desktop — Enable "File Access" in settings and grant it access to specific folders.

Test it: Ask the agent to create a simple text file:

Create a file called hello-agent.txt with the text "My first agent is running."

Check that the file appeared. If it did, congratulations — your agent just used a tool to affect the world.

Step 5: Run Your First Task

Now give it something real. Pick a small, safe task you've been putting off:

  • Rename a batch of files in a folder
  • Convert a Markdown file to HTML
  • Find all files older than 30 days in a directory
  • Read a configuration file and summarize its settings

Here's a template you can use for your prompt:

I need you to [specific task]. Here's what I know:
- The files are in [location]
- I want the output to look like [format]
- Don't modify anything outside [scope]

Show me what you did before you do it.

Watch how the agent works through the task. It will likely ask clarifying questions, read files, make changes, and report back. This is your first real agent interaction.

What to Do When It Goes Wrong

Things will go wrong. Here are the most common issues and how to fix them:

Symptom Cause Fix
"Authentication failed" API key is wrong or missing Regenerate the key and paste it carefully. Check for extra spaces.
"Model not found" Wrong model name in config Check the exact model ID on the provider's docs.
"Insufficient credits" No balance in your API account Add credits. Most providers need $5 minimum.
Agent does nothing Tool access not configured Check that file/command access is enabled in settings.

Your Takeaway — The Startup Checklist

After this lesson, you should have a working agent. Here's a checklist to confirm:

  • [ ] Harness installed (Opencode Desktop, Opencode CLI, or Claude Desktop)
  • [ ] API key created and connected
  • [ ] Test query answered correctly
  • [ ] File access enabled
  • [ ] One real task completed
← How Much Does an Agent Cost Per Hour? Paying for It: API Keys, Credits, and Subscriptions →