Want to use OpenCode on Windows without installing it directly on Windows? You can easily install and run OpenCode inside Windows Subsystem for Linux (WSL).
OpenCode is an open-source AI coding agent that helps you write code, build applications, debug projects, and interact with AI models directly from your terminal. It supports more than 200 AI providers and also offers access to several free AI models.
In this tutorial, I’ll show you how to install OpenCode inside WSL on Windows 11, step by step. We’ll first install WSL with Ubuntu, then install OpenCode, configure an AI model, and test whether everything is working correctly.
By the end of this guide, you’ll have a fully functional AI coding assistant running inside your Ubuntu terminal on Windows.
What You’ll Need Before Installing OpenCode
Before getting started, make sure you have:
- A Windows 10 or Windows 11 computer.
- An active internet connection.
- Administrator access to your Windows account.
- Windows PowerShell.
- Basic knowledge of using terminal commands.
You don’t need to install a separate Linux operating system or create a dual-boot environment. WSL allows you to run Linux directly inside Windows.
Step 1: Enable Windows Subsystem for Linux (WSL)
First, you need to enable Windows Subsystem for Linux on your Windows computer.
- Click the Windows search bar.
- Search for PowerShell.
- Find Windows PowerShell in the search results.
- Right-click it and select Run as administrator.
- Click Yes when Windows asks for permission.
Once PowerShell opens, execute the following command:
wsl --install
Press Enter to begin the installation.
This command automatically installs the Windows Subsystem for Linux and downloads Ubuntu as the default Linux distribution.
The installation may take a few moments, depending on your internet connection and system configuration.
Note: If Windows asks you to restart your computer, save your work and restart it to complete the installation.
Step 2: Set Up Ubuntu on Windows
Once WSL installation is complete, Ubuntu should launch automatically.
Now, you need to create your default Linux user account.
First, Ubuntu will ask you to enter a username.
For example:
mtl
Enter your preferred username and press Enter.
Next, create a password for your Ubuntu account. Enter the password and press Enter. Then, type it again to confirm.
Important: Linux terminals don’t display characters while you’re typing a password. You won’t see dots or asterisks. This is normal.
Once your account is created successfully, you’ll see the Ubuntu terminal prompt.
Congratulations! You’ve successfully installed Ubuntu inside Windows using WSL.
Step 3: Visit the Official OpenCode Website
Now that Ubuntu is ready, it’s time to download and install OpenCode.
Open your web browser and visit the official OpenCode website:
Official Website: https://opencode.ai
OpenCode is an open-source AI coding agent designed to help developers work with AI directly from their terminal.
Some of its key features include:
- Access to more than 200 AI providers.
- Support for free and paid AI models.
- Terminal-based coding assistance.
- AI-powered code generation and debugging.
- Integration with providers such as OpenAI, Anthropic, and Google.
- The ability to work with your local development projects.
You can also use OpenCode from your phone through supported workflows.
On the homepage, click the Install button to view the available installation methods.
You’ll find several installation options, including:
- curl
- npm
- Bun
- Homebrew
- Paru
Since we’re installing OpenCode inside Ubuntu on WSL, we’ll use the curl installation script or the npm command.
Step 4: Install OpenCode Inside WSL
Go to the installation section of the OpenCode website.
Choose the curl installation option and copy the provided command.
Alternatively, you can use the npm installation method if Node.js and npm are already installed in your Ubuntu environment.
Now, return to your Ubuntu terminal.
Paste the installation command and press Enter.
For the curl method, the command follows this format:
curl -fsSL https://opencode.ai/install | bash
This command downloads and runs the official OpenCode installation script.
The installer will automatically download the required files, install OpenCode, and configure the executable.
Once the installation finishes, OpenCode should be available through your terminal.
Important: Always copy the latest installation command from the official OpenCode website because installation methods and commands can change over time.
Step 5: Reload Your Ubuntu Terminal
After installing OpenCode, you may need to reload your shell configuration so Ubuntu recognizes the newly installed command.
Run the following command:
source ~/.bashrc
Press Enter to refresh your Bash environment.
This allows your terminal to recognize updated environment variables and PATH settings.
Step 6: Verify the OpenCode Installation
Now, let’s check whether OpenCode has been installed successfully.
Inside your Ubuntu terminal, execute:
opencode --version
Press Enter.
If everything is working correctly, the terminal will display the installed OpenCode version.
For example:
2.3.2
The version number may differ depending on the latest release available when you install it.
If you see a version number, congratulations! OpenCode is successfully installed inside WSL.
Step 7: Launch OpenCode in Ubuntu
Now comes the exciting part!
To launch your AI coding assistant, simply execute:
opencode
Press Enter.
OpenCode will open its interactive terminal interface.
From here, you can interact with AI models, generate code, work on projects, and build applications directly from your Ubuntu environment.
Step 8: Select a Free AI Model
One of the best features of OpenCode is its support for multiple AI models.
You don’t necessarily need to purchase an API subscription to get started. You can explore the free models available through the supported OpenCode model catalog.
To view the available models, type:
/models
Press Enter.
OpenCode will display a list of available models.
Depending on current availability, you may find free models such as:
- Big Pickle
- DeepSeek V4.1 Flash Free
- SY4 Flash Free
- Iceman Free
- LongCat
- Beam
- Mimo V2.6
- Nemotron
Select the model you want to use.
For this tutorial, I’ll select Big Pickle as the default model.
Keep in mind that model availability, names, and free usage limits can change over time.
Step 9: Connect Additional AI Providers (Optional)
Besides the built-in free models, OpenCode allows you to connect external AI providers.
If you already have an API key from an AI provider, you can connect it to OpenCode.
Inside the OpenCode interface, press:
Ctrl + A
This opens the provider selection interface.
You’ll find several popular integrations, including:
- OpenCode Go
- OpenAI
- GitHub Copilot
- Anthropic
For example, if you want to connect Anthropic, select Anthropic from the provider list.
OpenCode will ask you to provide your API key.
Paste your Anthropic API key and press Enter to authenticate.
Once authentication is successful, you can use supported Anthropic models inside OpenCode.
You can follow a similar process to connect other supported providers.
Tip: If you don’t have an API key, you can continue using the available free models instead.
Step 10: Test OpenCode to Make Sure It’s Working
Now let’s perform a quick test to confirm that your AI coding assistant is working correctly.
Make sure you’ve selected a model, such as Big Pickle.
Inside the OpenCode terminal interface, type:
hi
Press Enter.
Within a few seconds, the selected AI model should respond to your message.
If you receive a response, everything is working correctly!
You’ve successfully installed OpenCode inside Windows Subsystem for Linux and connected it to an AI model.
Common OpenCode Installation Problems and Solutions
Sometimes, you may encounter a few issues while installing or running OpenCode inside WSL. Here are some common problems and their solutions.
1. ‘wsl’ Is Not Recognized
If PowerShell displays an error saying that wsl is not recognized, make sure you’re running a supported version of Windows.
You can also update Windows and check whether the WSL feature is enabled.
2. OpenCode Command Not Found
If Ubuntu displays:
opencode: command not found
Try reloading your Bash configuration:
source ~/.bashrc
Then check the installation again:
opencode --version
If the problem continues, verify that the OpenCode installation directory is included in your PATH.
3. OpenCode Installation Fails
If the installation script fails, check your internet connection and make sure the required dependencies are available.
You can also revisit the official installation page to copy the latest installation command.
4. AI Model Doesn’t Respond
If an AI model doesn’t respond, check your internet connection and verify that the selected model is currently available.
For external providers, make sure you’ve configured a valid API key and have sufficient usage quota.
Frequently Asked Questions (FAQ)
1. Can I install OpenCode on Windows 11?
Yes. You can install OpenCode directly on Windows or run it inside Windows Subsystem for Linux (WSL). This tutorial demonstrates the WSL installation method using Ubuntu.
2. Is OpenCode free to use?
OpenCode is an open-source AI coding agent. However, using AI models may involve additional costs depending on the provider and model you choose. Some supported models offer free access with usage limitations.
3. Do I need Ubuntu to run OpenCode inside WSL?
Ubuntu is a popular Linux distribution for WSL and is the default distribution installed by the wsl --install command on supported Windows systems. Other supported Linux distributions may also work.
4. Can I use OpenAI or Claude models with OpenCode?
Yes. OpenCode supports multiple AI providers, including OpenAI and Anthropic. You can connect supported providers using their respective authentication methods or API keys.
5. Can I use OpenCode without an API key?
Yes. You can use available free models through supported integrations without configuring your own external provider API key. Availability and usage limits depend on the model and service.
6. How do I check the installed OpenCode version?
Open your Ubuntu terminal and run:
opencode --version
The terminal will display your installed version.
Final Thoughts
That’s it! You’ve successfully learned how to install OpenCode inside WSL on Windows 11.
We started by enabling Windows Subsystem for Linux, installed Ubuntu, configured a Linux user account, and installed OpenCode using the official installation script.
We also explored how to select free AI models, connect external providers such as OpenAI and Anthropic, and test the AI assistant directly from the terminal.
Now you can start using OpenCode to generate code, debug applications, build projects, and improve your development workflow.
If you found this tutorial helpful, don’t forget to share it with other developers who want to explore AI-powered coding tools.
Watch the complete video tutorial: [Insert Your YouTube Video Link Here]
Happy coding!