In this categoryLocal AI · 24
Local AIBeginner

How to Run OpenAI's gpt-oss-20b Locally with Ollama

gpt-oss-20b is OpenAI's first open-weight model under Apache 2.0, and it runs on a 16 GB machine. Here is the exact, step-by-step setup with Ollama, from install to your first chat and API call.

9 minBeginner

OpenAI spent years as the company that made "open" a punchline. That changed with gpt-oss. The 20B variant is the first OpenAI model you can download, run on your own machine, and use commercially under the Apache 2.0 license — no API key, no per-token bill, no data leaving your computer. The best part: it fits on a 16 GB laptop or GPU. This guide walks through the entire setup with Ollama, the simplest way to run it, and gets you from a blank terminal to a working local chat in about ten minutes.

What gpt-oss-20b actually is

gpt-oss-20b is a mixture-of-experts (MoE) model with 20.9 billion total parameters but only 3.6 billion active per token. That design is why it punches far above its size class on speed: it generates tokens at roughly the pace of a 7B model while carrying the knowledge of a 20B one. It ships with a 128K context window, native function calling, web-browsing support, and a configurable reasoning effort (low, medium, high) so you can trade speed for depth on a per-request basis. OpenAI quantized it to MXFP4 out of the box, which is what keeps the memory footprint small enough for consumer hardware.

Two sizes exist
There are two gpt-oss models: gpt-oss-20b (runs on 16 GB) and gpt-oss-120b (needs roughly 60–80 GB, so a high-end GPU or a 64 GB+ unified-memory Mac). This guide covers the 20b — it is the one almost everyone should start with. See our gpt-oss-20b vs 120b guide if you are deciding between them.

What you need before you start

  • 16 GB of memory — VRAM on a discrete GPU (RTX 4060 Ti 16 GB, RTX 5070 Ti, or better), or 16 GB of unified memory on an Apple Silicon Mac (M1 through M4).
  • About 13 GB of free disk space for the model download.
  • Windows, macOS, or Linux. Ollama runs on all three.
  • No GPU at all? It still runs on CPU with 16 GB of system RAM, just slower (a handful of tokens per second instead of dozens).

Step 1 — Install Ollama

Ollama is a free, open-source runner that handles the download, quantization, and serving for you. On macOS or Windows, download the installer from ollama.com and run it. On Linux, one command does it:

zsh — install ollama (Linux)
$curl -fsSL https://ollama.com/install.sh | sh
>>> Installing ollama to /usr/local/bin...
>>> Ollama is running on http://127.0.0.1:11434
$

Confirm it installed by checking the version. If you see a version number, you are ready.

zsh — verify
$ollama --version
ollama version is 0.x.x
$

Step 2 — Pull and run gpt-oss-20b

This is the whole installation. One command downloads the model (about 13 GB, so give it a few minutes on a normal connection) and drops you straight into an interactive chat:

zsh — run gpt-oss-20b
$ollama run gpt-oss:20b
pulling manifest
pulling gpt-oss-20b... 100% ▕████████████▏ 13 GB
success
You are now at the >>> prompt — type a message and press Enter.
$>>> Write a Python function that reverses a linked list.
Here is a clean iterative solution...
$
Pull without chatting
If you just want to download the model now and use it later, run ollama pull gpt-oss:20b instead. It fetches the weights without opening a chat session.

To exit the chat, type /bye or press Ctrl+D. The model stays on disk, so the next ollama run gpt-oss:20b launches instantly with no download.

Step 3 — Control the reasoning effort

One of gpt-oss's standout features is adjustable reasoning. For a quick factual answer you want speed; for a hard coding or math problem you want it to think. You set this in the system prompt. Inside the chat, use /set system to switch levels:

zsh — set reasoning effort
$>>> /set system Reasoning: high
Set system message.
$>>> Prove that the square root of 2 is irrational.
(model now spends more time reasoning before answering)
$

Use Reasoning: low for fast chat and autocomplete-style tasks, Reasoning: medium as a balanced default, and Reasoning: high when correctness matters more than latency. Higher effort uses more tokens and takes longer, but noticeably improves multi-step problems.

Step 4 — Use it from code (OpenAI-compatible API)

Ollama exposes an OpenAI-compatible endpoint at http://localhost:11434/v1, which means most code written for the OpenAI API works against your local model by changing two lines. Here is a raw curl call:

chat.sh
curl http://localhost:11434/v1/chat/completions \
  -H "Content-Type: application/json" \
  -d '{
    "model": "gpt-oss:20b",
    "messages": [
      { "role": "system", "content": "Reasoning: medium" },
      { "role": "user", "content": "Explain MoE models in two sentences." }
    ]
  }'

And the same thing from Python using the official openai library — point it at your local server and use any string as the API key:

local_gpt_oss.py
from openai import OpenAI

client = OpenAI(
    base_url="http://localhost:11434/v1",
    api_key="ollama",  # required by the library, but ignored locally
)

resp = client.chat.completions.create(
    model="gpt-oss:20b",
    messages=[
        {"role": "system", "content": "Reasoning: high"},
        {"role": "user", "content": "Refactor this loop into a list comprehension: ..."},
    ],
)

print(resp.choices[0].message.content)
Drop-in replacement
Because the endpoint is OpenAI-compatible, you can point existing tools — Continue.dev, Open WebUI, Aider, LangChain, or your own app — at localhost:11434/v1 and select gpt-oss:20b. No API bill, and your prompts never leave the machine.

Step 5 — Add a chat UI with Open WebUI (optional)

The terminal is fine for testing, but for daily use you probably want a ChatGPT-style interface. Open WebUI is the most popular option and connects to Ollama automatically. If you have Docker installed, one command runs it:

zsh — run Open WebUI
$docker run -d -p 3000:8080 --add-host=host.docker.internal:host-gateway -v open-webui:/app/backend/data --name open-webui ghcr.io/open-webui/open-webui:main
Then open http://localhost:3000 and pick gpt-oss:20b from the model dropdown.
$

Troubleshooting

ProblemFix
"out of memory" or the model won't loadYou are under 16 GB of free VRAM/RAM. Close other apps, or run the model on CPU by unplugging the GPU offload (Ollama falls back automatically when VRAM is short).
Very slow, only a few tokens per secondIt is running on CPU, not your GPU. Confirm your GPU has 16 GB free; on a 12 GB card some layers spill to CPU and slow things down.
"model not found"Check the exact tag: it is gpt-oss:20b with a colon, not a slash. Run ollama list to see what you have pulled.
Want to free disk spaceRun ollama rm gpt-oss:20b to delete the weights. Re-pull anytime.

The bottom line

gpt-oss-20b is the easiest way to run a genuinely capable OpenAI model entirely on your own hardware, for free, with a commercial-friendly license. Three commands — install Ollama, pull the model, run it — and you have a private assistant that handles coding, reasoning, and tool calls without an internet connection. For anyone who has wanted to drop their ChatGPT subscription for everyday tasks, this is the first OpenAI release that makes it realistic.

Local models run better with more VRAM. CompareRTX GPUs on Amazonbefore you upgrade.(affiliate link. We may earn a commission at no extra cost. Disclosure)

Related guides

Watch related tutorials

Free weekly email

Weekly local AI drops

New models, what runs on your hardware, and the guides to set them up. One email a week, unsubscribe any time.

Tags
#gpt-oss-20b ollama#run gpt-oss locally#run openai model locally#gpt-oss setup#openai open source model#gpt-oss-20b