> ## Documentation Index
> Fetch the complete documentation index at: https://gomodel-docs-providers-restructure.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 can register multiple Ollama providers through suffixed environment
variables.

Flow:

`Client -> GoModel -> ollama-a / ollama-b`

## 1. Run GoModel with multiple Ollama base URLs

```bash theme={null}
docker run --rm --name gomodel \
  -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:latest
```

`OLLAMA_A_BASE_URL` registers provider `ollama-a`. `OLLAMA_B_BASE_URL`
registers provider `ollama-b`.

Use different ports or hostnames for each Ollama instance.

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

<Note>
  Use YAML only when generated provider names such as `ollama-a` and
  `ollama-b` are not enough or you need a larger structured provider block.
</Note>

## 2. Verify the model registry

```bash theme={null}
curl -s http://localhost:8080/v1/models \
  -H "Authorization: Bearer change-me"
```

Expected model IDs will be provider-qualified, for example:

* `ollama-a/llama3.2`
* `ollama-b/llama3.2`

## 3. Route to a specific Ollama 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."}]
  }'
```

If you send only the bare model name such as `llama3.2` and both providers
expose it, GoModel will route the request to one provider based on provider
registration order. To choose a specific Ollama backend, use the qualified form
such as `ollama-a/llama3.2` or `ollama-b/llama3.2`.

## 4. When YAML still makes sense

Use `config.yaml` when you need custom provider names, per-provider resilience
overrides, or a larger structured config:

```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"
```

This pattern relies on the same suffixed env auto-discovery used across GoModel
providers: `OLLAMA_A_BASE_URL` registers `ollama-a`, and `OLLAMA_B_BASE_URL`
registers `ollama-b`.
