A coding assistant needs a model provider as well as an installed command-line tool. Ollama's integration launcher connects OpenCode to a selected local model and starts it with provider settings supplied for that process.

OpenCode must already be installed and available in the same shell as Ollama. A running local Ollama server and a downloaded text model are also required; local inference needs no account or API key. An empty scratch directory is a suitable starting location because OpenCode can read files, edit them, and execute shell commands in its working directory.

The small qwen2.5:0.5b model needs roughly 398 MB of model storage and can answer a short connection-test question. OpenCode sends its own instructions along with a question, so even a brief exchange needs more context than the question alone. Repository work needs a capable coding model; Ollama specifies at least 64k context for OpenCode, beyond this model's native 32k capacity.

Steps to launch an Ollama integration:

  1. Locate qwen2.5:0.5b in Ollama's installed models.
    $ ollama list
    NAME            ID              SIZE      MODIFIED       
    qwen2.5:0.5b    6467b5fd1dd4    397 MB    59 seconds ago

    The model must be installed on the server reached by this shell. A connection error means that server is unavailable; a missing model needs downloading before launch.
    Related: How to pull an Ollama model

  2. Check that the OpenCode executable is available in the current shell.
    $ opencode --version
    1.19.4

    A version number confirms that Ollama can find the installed client. If the command is missing, OpenCode needs installation before launch. OpenCode installation instructions

  3. Save a context setting for the connection test in Modelfile.opencode.
    Modelfile.opencode
    FROM qwen2.5:0.5b
    PARAMETER num_ctx 16384

    A 16,384-token context leaves room for OpenCode's instructions and the short reply without exceeding this model's capacity. The usual 4k context can truncate those instructions. Larger contexts use more memory; this setting does not make the small model suitable for repository coding.

  4. Create the local qwen2.5-opencode:0.5b model from that file.
    $ ollama create qwen2.5-opencode:0.5b -f Modelfile.opencode

    The new name reuses the installed weights with the context setting. It leaves qwen2.5:0.5b unchanged.
    Related: How to create a custom Ollama model

  5. Launch OpenCode through Ollama with a short arithmetic question.
    $ ollama launch opencode \
      --model qwen2.5-opencode:0.5b --yes -- \
      run "What is 17 plus 25? Answer in one short sentence."
     
    > build · qwen2.5-opencode:0.5b
     
    "`17 + 25 = 42"`

    The --model value selects Ollama's installed model. --yes answers Ollama's confirmation prompts, including its warning that this small model does not work well with OpenCode. Arguments after -- go to OpenCode; run submits one prompt and returns to the shell after the answer.

    The model label and an answer expressing 42 show that OpenCode received a reply through the selected Ollama integration. Wording can vary, and CPU inference can take time. Ollama supplies the provider configuration to the launched process without replacing existing OpenCode provider settings on disk.

Share this guide