Connecting to an AI Provider
00:00
Now that you’ve installed OpenCode and have an API key, let’s go ahead and connect OpenCode to your provider. So start by running the command opencode and then press Enter.
00:12
Once you’re inside the interface, you want to run the command /connect to pick the provider that you’re going to use. Now you can either use the arrow keys to go through the list of providers looking for the one you want to use, or you can type the name of the provider.
00:31 Press Enter to select it. You’ll be prompted to paste the API key. Go ahead and paste the key, and press Enter again. After connecting, it’s very likely that you’ll be asked to pick the model from the provider that you’re going to use.
00:47 For this video course, you don’t need anything very powerful because the project is fairly simple. So go ahead and pick a modest model that won’t cost you a lot of money and that will allow you to get results pretty fast.
01:02 For example, for Google, Gemini 2.5 Flash should be enough. And then you might also be asked about the reasoning effort or the variant for that model, which is going to define how much time and how many tokens the agent spends in the reasoning or quote unquote thinking phase.
01:24 If you have that prompt, feel free to pick the default for now. And then to test that the connection was successful, you can prompt the model with something like, “Tell me a joke”.
01:37 You give it a second and you should see a joke on the screen, which hopefully cracks you up. I’ve been making so many demos with agents that I’ve read this joke a hundred times in the last few weeks, so I don’t find it funny anymore. But this is a pretty clever joke, so I hope you can appreciate it.
01:56
Once you’ve tested the connection, you can check that OpenCode can see your files. Go ahead and exit OpenCode, and make sure you’re at the root of the rpcontacts project.
02:11 And go ahead and open OpenCode at that location. Make sure you’re there. And then you can try asking something about your project specifically. For example, you could ask, what’s the name of this Python project?
02:27
And the agent should figure out, this was pretty fast, you can see that the project name is rpcontacts. So if your agent is able to figure out the name of the project, it’s because everything is working just fine.
02:43 If not, go ahead and troubleshoot your installation before you proceed to the next lesson where you’re going to explore the OpenCode interface.
Become a Member to join the conversation.