You will install OpenCode, point it at an Ollama server on your local network, and set a local model as the default. This suits anyone who wants an AI coding agent without paid API keys. You need Ollama running with a model already pulled, plus a Windows PC.
YouTube video: Run OpenCode Locally with Ollama : No Paid API Needed! + Agentic AI Coding
YouTube’s video details do not confirm captions. Check CC in the player for available tracks.
Choose a chapter (12)
- Video length
- 11 min 30 s
- Time to do it
- 20 minutes
- Difficulty
- Medium
- Steps
- 9
What you need
Steps
Install OpenCode on your machine using its official installer or package manager, then confirm the command runs in a terminal.
Understand the two parts: OpenCode is the client, and Ollama serves the model over an HTTP endpoint on your network.
Check the Ollama server is reachable by opening its address and port in a browser or sending a request to its API.
Create the global OpenCode configuration file in your user config folder so the settings apply to every project.
In the config, add an Ollama provider block with the schema version, provider name and the base URL of your server.
List the local models you want to use under that provider, matching the model names Ollama reports.
Set one of those models as the default so OpenCode picks it without asking each time.
Launch OpenCode from your project folder and send a short test prompt to confirm the model answers.
Watch memory usage on the Ollama machine while the model loads and responds, and pick a smaller model if it runs out.
Tips and common mistakes
Use the exact model name Ollama lists, or the connection will fail.
Keep the Ollama server on the same fast local network to avoid slow responses.
Start with a smaller model if your machine has limited memory.
Back up your config file before editing so you can restore a working setup.
Questions
Do I need a paid API key?
No. OpenCode talks to your own Ollama server, so no paid API is involved.
Can Ollama run on a different computer?
Yes. Point the base URL at that machine's address and port instead of localhost.
Why does OpenCode not see my model?
The model name in the config must match what Ollama reports, and the server must be reachable from your machine.
The notes are drafted automatically from video details and general task knowledge. How the guide was prepared
Report a correction


