Before the session

Get your key from a model provider

OpenCode is the tool, but it doesn't come with a model inside: it connects to one that runs in the cloud. To connect it you need a key (API key) from a model provider. In this lesson you choose a provider, create your account, and save your key. It takes about 5 minutes.

A fair warning: these steps are about real websites, and websites change. This guide is from September 2026. If a button has a different name, the logic is the same.

What a key is

An API key is a secret string of text that tells the provider the request is yours. It's like your house key: it lets you in, and that's why you don't lend it to anyone or paste it in a chat.

Choose your provider

There are two paths that work well for the workshop. Both give you free models.

OpenRouterOpenCode Zen
What it isA service that gives you access to many models from a single accountThe model service from the makers of OpenCode
Cost of the free models00
Does it ask for a card or billing details?No, for the free modelsYes, to give you the key
Free usage limit20 requests per minute and 50 per dayDepends on the model
Where to get the keyopenrouter.ai, Keys sectionopencode.ai/auth

If you don't want to give any payment details, use OpenRouter. It's the path we follow live.

About the 50 requests per day limit: an agent makes several requests for each job (it reads a file, thinks, writes another), so 50 is enough for the session and for practicing for a while, not for working all day. If you run out one day, it's not an error: it's the free plan doing its job.

Path A: OpenRouter

  1. Go to openrouter.ai and create an account (you can use Google or GitHub).
  2. In your account menu, go to Keys.
  3. Create a new key (Create Key) and give it a name you'll recognize, for example agent-workshop.
  4. Copy it and save it right then. The full key is shown only once. If you close the window without copying it, you'll have to create another one (no big deal, but you save yourself the step).

The key looks something like this: sk-or-v1-xxxxxxxxxxxx. That sk-or prefix is normal.

Path B: OpenCode Zen

  1. Go to opencode.ai/auth and sign in.
  2. Add your billing details. Models marked as free don't generate any charges.
  3. Copy your key and save it.

A note on privacy that applies to both paths: several free models use what you write to them to improve their models. For the workshop we work with sample data, so it doesn't matter. As a general rule, don't give a free model personal data or information from your job.

Plan B, in case your provider fails

Every account is its own world. If neither of the two works for you, Groq (console.groq.com) also has a free tier: account, API Keys, Create API Key, copy. OpenCode connects to Groq the same way as to the other two.

Keep your key safe

  • Save it in a password manager or in a private note.
  • Don't paste it in the video call chat or show it on screen.
  • If it ever leaks, go to the provider, delete it, and create another one. It's free and takes a minute.

Check that you're ready

  • I have an account on OpenRouter (or on OpenCode Zen, or on Groq).
  • I created a key and saved it where I can find it.
What if I lost the key?

Go back to the keys section, delete the old one, and create a new one. This time, copy it as soon as it appears.

Summary

  • OpenCode needs a key from a model provider to work.
  • OpenRouter gives you free models without a card, with a cap of 50 requests per day. OpenCode Zen also has free models, but it asks for billing details.
  • With your key saved, you're ready for the session.

Resources