{"id":5183,"date":"2026-11-18T21:24:12","date_gmt":"2026-11-18T21:24:12","guid":{"rendered":"https:\/\/bitflow-solutions.com\/guias-tecnicas\/ollama-local-models-coding-agent\/"},"modified":"2026-11-18T21:24:12","modified_gmt":"2026-11-18T21:24:12","slug":"ollama-local-models-coding-agent","status":"publish","type":"bf_guia","link":"https:\/\/bitflow-solutions.com\/en\/guias-tecnicas\/ollama-local-models-coding-agent\/","title":{"rendered":"Ollama on Windows: install it, download a model and use it with a coding agent"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">A practical guide to running <strong>AI models on your own machine with Ollama<\/strong>: installing it on Windows, downloading and trying a model, setting the context that agents need and connecting it to <strong>OpenCode<\/strong> or <strong>Claude Code<\/strong> so you can code without sending your code anywhere. All the commands are also in the <strong>README.md<\/strong> on the left.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">What you\u2019ll learn<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>What <strong>Ollama<\/strong> is and why you would run AI models on your own machine.<\/li>\n\n\n<li>How to install Ollama on Windows and check that it works.<\/li>\n\n\n<li>How to download a model, try it in the terminal and manage the models you have downloaded.<\/li>\n\n\n<li>How to set the context length that coding agents need.<\/li>\n\n\n<li>How to connect an agent (<strong>OpenCode<\/strong> or <strong>Claude Code<\/strong>) to your local model.<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Windows 10 22H2<\/strong> or later (Home or Pro); no administrator rights needed. macOS 14 or later and Linux also work.<\/li>\n\n\n<li>A graphics card helps a lot: <strong>NVIDIA<\/strong> with driver 551.61 or later, or a compatible <strong>AMD<\/strong> card. Without one it runs on the processor, more slowly.<\/li>\n\n\n<li>Disk space: around 4 GB for Ollama, plus whatever each model takes (from a few GB to hundreds).<\/li>\n\n\n<li>For the last step, an installed agent: OpenCode or Claude Code (see the basic setup guide for an AI coding agent).<\/li>\n\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step by step<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">1. Understand what Ollama does<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Ollama downloads <strong>open AI models<\/strong> and runs them on your machine, with a local API at <code>http:\/\/localhost:11434<\/code>. Ollama itself is not an agent: it is the \u201cengine\u201d that a coding agent such as OpenCode or Claude Code can use instead of a model in the cloud.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The main benefit is privacy: with local models, your prompts and your code never leave your machine. In return, the models that fit on a laptop are usually less capable than the large cloud models.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Install Ollama<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">On Windows, download the installer from ollama.com\/download (it installs into your user folder and keeps itself up to date) or install it from PowerShell. Then check the version and that the service responds \u201cOllama is running\u201d:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Option 1: the Windows installer (OllamaSetup.exe, at https:\/\/ollama.com\/download)\n# Option 2: from PowerShell\nirm https:\/\/ollama.com\/install.ps1 | iex\n\n# Check the version and that the service responds\nollama -v\ncurl.exe http:\/\/localhost:11434<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">On Linux and macOS:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Linux (and macOS)\ncurl -fsSL https:\/\/ollama.com\/install.sh | sh\nollama -v<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">In PowerShell type <code>curl.exe<\/code>, not <code>curl<\/code>: <code>curl<\/code> is an alias for a different command.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">3. Download a model and try it<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Models are downloaded by name from the library at ollama.com\/library. <code>ollama run<\/code> opens a chat in the terminal:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Download a model and chat with it in the terminal (leave with \/bye)\nollama pull qwen3.5\nollama run qwen3.5\n\n# Manage your models\nollama ls                 # the models you have downloaded\nollama ps                 # the ones loaded right now (and whether they use GPU or CPU)\nollama stop qwen3.5       # unload the model from memory\nollama rm qwen3.5         # delete the model from disk<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Some coding-oriented models in the library, with their download size:<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Model<\/th><th>Tag<\/th><th>Approximate download<\/th><\/tr><\/thead><tbody><tr><td>Qwen3.5<\/td><td><code>qwen3.5<\/code> (9b)<\/td><td>7 GB<\/td><\/tr><tr><td>Qwen2.5-Coder<\/td><td><code>qwen2.5-coder:7b<\/code> \u00b7 <code>:14b<\/code> \u00b7 <code>:32b<\/code><\/td><td>4.7 GB \u00b7 9 GB \u00b7 20 GB<\/td><\/tr><tr><td>Devstral<\/td><td><code>devstral<\/code> (24b)<\/td><td>14 GB<\/td><\/tr><tr><td>gpt-oss<\/td><td><code>gpt-oss:20b<\/code><\/td><td>14 GB<\/td><\/tr><tr><td>Qwen3-Coder<\/td><td><code>qwen3-coder<\/code> (30b)<\/td><td>19 GB<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Start with a small one and use <code>ollama ps<\/code> to check whether it runs on the GPU (PROCESSOR column): if it shows CPU, the model does not fit in your graphics card\u2019s memory and will be slower.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">4. Call it from the API<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Any application on your machine can use the model through the local API:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Ollama's native API (PowerShell adaptation of the curl example in the documentation)\nInvoke-RestMethod -Uri http:\/\/localhost:11434\/api\/generate -Method Post -ContentType 'application\/json' `\n  -Body '{\"model\":\"qwen3.5\",\"prompt\":\"Write a Python function that adds two numbers\",\"stream\":false}'\n\n# OpenAI-compatible API, for tools that already use it:\n#   http:\/\/localhost:11434\/v1\/   (they ask for a key, but Ollama ignores it)<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5. Set the context for agents<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Coding agents send a lot of text with every request (files, instructions, command output). OpenCode and Claude Code need a context of <strong>64,000 tokens or more<\/strong>, and by default Ollama uses less if your card has little memory. On Windows, you change it with an environment variable:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>1. Quit Ollama from its icon in the taskbar.\n2. Search for \"environment variables\" in Settings and open \"Edit environment variables for your account\".\n3. Create the variable OLLAMA_CONTEXT_LENGTH with the value 64000.\n4. Click OK and open Ollama again from the Start menu.<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">A larger context takes more memory: if the model starts running on the CPU, try a smaller one.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">6. Connect a coding agent<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The simplest way is <code>ollama launch<\/code>, which opens the agent already set up to use Ollama:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Open an agent already connected to Ollama (if you do not give a model, it lets you choose)\nollama launch opencode --model qwen3.5\nollama launch claude --model qwen3.5\n\n# Only configure OpenCode to use Ollama, without opening it\nollama launch opencode --config<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">OpenCode also detects Ollama on its own when it is running: in OpenCode, run <code>\/connect<\/code>, choose Ollama and then the model with <code>\/models<\/code>. You can also set up Claude Code by hand, pointing it at the Ollama API:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code># Claude Code against Ollama, by hand (only for this PowerShell window)\n$env:ANTHROPIC_AUTH_TOKEN = \"ollama\"\n$env:ANTHROPIC_API_KEY = \"\"\n$env:ANTHROPIC_BASE_URL = \"http:\/\/localhost:11434\"\nclaude --model qwen3.5\n# Inside Claude Code, \/status shows what it is connecting to<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">7. Keep Ollama on your own machine<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">By default Ollama only listens on your own machine (<code>127.0.0.1:11434<\/code>). If you change <code>OLLAMA_HOST<\/code> to <code>0.0.0.0<\/code>, anyone who can reach your machine over the network will be able to use your models: the local API does not check keys. Only do it on a trusted network and behind a firewall.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Common errors<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">curl.exe http:\/\/localhost:11434 does not respond<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Ollama is not running. Open it from the Start menu (its icon should appear in the taskbar) and try again. Check the logs in <code>%LOCALAPPDATA%\\Ollama<\/code> (<code>server.log<\/code> and <code>app.log<\/code>).<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The model is very slow<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Look at <code>ollama ps<\/code>: if the PROCESSOR column shows CPU, or a split between CPU and GPU, the model does not fit in your graphics card\u2019s memory. Use a smaller model or reduce the context. Also check that your NVIDIA driver is 551.61 or later.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">The agent does not use its tools properly or \u201cforgets\u201d earlier work<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">The context is too small. Raise <code>OLLAMA_CONTEXT_LENGTH<\/code> to 64000 or more (step 5) and restart Ollama. A model designed for coding also helps.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">I changed an environment variable and nothing happened<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Ollama reads its variables when it starts. Quit it from the taskbar icon (closing the window is not enough) and open it again from the Start menu.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">I am running out of disk space<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Check what you have downloaded with <code>ollama ls<\/code> and delete what you do not use with <code>ollama rm<\/code>. Models are stored in <code>C:\\Users\\&lt;user&gt;\\.ollama\\models<\/code>; to store them on another disk, set <code>OLLAMA_MODELS<\/code> as in step 5.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">It does not download models behind the company proxy<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Set the <code>HTTPS_PROXY<\/code> variable to the proxy address (do not use <code>HTTP_PROXY<\/code>) and restart Ollama.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Next steps<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Set up the agent, its context and its permissions (see the basic setup guide for an AI coding agent).<\/li>\n\n\n<li>Compare several models from the library on the same task from your project before choosing one.<\/li>\n\n\n<li>Integrate the local API into your applications through the OpenAI compatibility (<code>http:\/\/localhost:11434\/v1\/<\/code>).<\/li>\n\n\n<li>Combine local models for tasks involving sensitive data with cloud models for the most complex ones.<\/li>\n\n<\/ul>\n\n\n","protected":false},"excerpt":{"rendered":"<p>Install Ollama, download and try an AI model on your own machine, set the context that agents need and connect it to OpenCode or Claude Code so you can code without sending your code anywhere.<\/p>\n","protected":false},"featured_media":0,"template":"","bf_tecnologia":[107,105],"bf_nivel":[108],"class_list":["post-5183","bf_guia","type-bf_guia","status-publish","hentry","bf_tecnologia-ai","bf_tecnologia-development","bf_nivel-basic"],"acf":[],"_links":{"self":[{"href":"https:\/\/bitflow-solutions.com\/en\/wp-json\/wp\/v2\/bf_guia\/5183","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/bitflow-solutions.com\/en\/wp-json\/wp\/v2\/bf_guia"}],"about":[{"href":"https:\/\/bitflow-solutions.com\/en\/wp-json\/wp\/v2\/types\/bf_guia"}],"version-history":[{"count":0,"href":"https:\/\/bitflow-solutions.com\/en\/wp-json\/wp\/v2\/bf_guia\/5183\/revisions"}],"wp:attachment":[{"href":"https:\/\/bitflow-solutions.com\/en\/wp-json\/wp\/v2\/media?parent=5183"}],"wp:term":[{"taxonomy":"bf_tecnologia","embeddable":true,"href":"https:\/\/bitflow-solutions.com\/en\/wp-json\/wp\/v2\/bf_tecnologia?post=5183"},{"taxonomy":"bf_nivel","embeddable":true,"href":"https:\/\/bitflow-solutions.com\/en\/wp-json\/wp\/v2\/bf_nivel?post=5183"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}