> ## Documentation Index
> Fetch the complete documentation index at: https://gomodel-docs-benchmark-writeup-and-tooling.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Ollama

> Use one GoModel instance with multiple Ollama providers through suffixed environment variables and provider-qualified model IDs.

GoModel registers Ollama through `OLLAMA_BASE_URL`. To run multiple Ollama
instances behind one gateway, use suffixed env vars.

## Configure

```bash theme={null}
OLLAMA_A_BASE_URL=http://host.docker.internal:11434/v1
OLLAMA_B_BASE_URL=http://host.docker.internal:11435/v1
GOMODEL_MASTER_KEY=change-me
```

`OLLAMA_A_BASE_URL` registers provider `ollama-a`; `OLLAMA_B_BASE_URL`
registers `ollama-b`. Use different ports or hostnames per instance.

<Tip>
  On Linux, add `--add-host=host.docker.internal:host-gateway` to the
  `docker run` command so the container can reach Ollama on the host.
</Tip>

## Run GoModel

<CodeGroup>
  ```bash Docker (.env file) theme={null}
  docker run --rm -p 8080:8080 --env-file .env enterpilot/gomodel
  ```

  ```bash Docker (inline -e) theme={null}
  docker run --rm -p 8080:8080 \
    -e GOMODEL_MASTER_KEY="change-me" \
    -e OLLAMA_A_BASE_URL="http://host.docker.internal:11434/v1" \
    -e OLLAMA_B_BASE_URL="http://host.docker.internal:11435/v1" \
    enterpilot/gomodel
  ```

  ```bash Binary (make build) theme={null}
  make build
  ./bin/gomodel
  ```
</CodeGroup>

## Route to a specific backend

```bash theme={null}
curl -s http://localhost:8080/v1/chat/completions \
  -H "Authorization: Bearer change-me" \
  -H "Content-Type: application/json" \
  -d '{
    "model": "ollama-a/llama3.2",
    "messages": [{"role": "user", "content": "Reply with exactly ok."}]
  }'
```

`GET /v1/models` returns provider-qualified IDs such as `ollama-a/llama3.2`
and `ollama-b/llama3.2`. A bare model name is routed to whichever provider
exposes it first by registration order — use the qualified form to pick
explicitly.

## When YAML still helps

Reach for `config.yaml` only when generated names like `ollama-a` are not
enough, or when you want per-provider resilience overrides:

```yaml theme={null}
providers:
  local-fast:
    type: ollama
    base_url: "http://ollama-fast:11434/v1"

  local-large:
    type: ollama
    base_url: "http://ollama-large:11434/v1"
```
