Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 82 additions & 0 deletions docs/advanced/config-yaml.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
---
title: "config.yaml"
description: "When to use config.yaml, when not to, and how it interacts with environment variables and Docker."
---

The goal in GoModel is to make `config.yaml` optional as much as possible.
Prefer environment variables for normal deployments, CI, containers, and secret
injection.

Use `config.yaml` when you need structure that env vars cannot express cleanly,
especially:

- multiple providers with the same type
- custom provider instance names such as `ollama-a`, `ollama-b`, or `my-openai`
- larger nested config that is easier to review in one file

## Priority Order

Effective precedence is:

1. environment variables
2. optional `config/config.yaml` or `config.yaml`
3. built-in defaults from code

`.env` is not a separate priority layer. It is just a convenient way to load
environment variables before startup.

## When `config.yaml` Is Better

YAML is the current way to define multiple providers of the same type with
flexible names:

```yaml
providers:
ollama-a:
type: ollama
base_url: "http://host.docker.internal:11434/v1"

ollama-b:
type: ollama
base_url: "http://host.docker.internal:11435/v1"
```

That gives you provider-qualified model IDs such as `ollama-a/llama3.2` and
`ollama-b/llama3.2`.

## Current Schema

The current source of truth lives in the main codebase:

- [config/config.go](https://github.com/ENTERPILOT/GoModel/blob/main/config/config.go)
- [config/config.example.yaml](https://github.com/ENTERPILOT/GoModel/blob/main/config/config.example.yaml)

## Docker

GoModel reads `config/config.yaml` first, then `config.yaml`.

With `docker run`, you can keep a host file named `config.yml` and mount it to
the in-container path GoModel expects:

```bash
docker run --rm -p 8080:8080 \
-v "$PWD/config.yml:/app/config/config.yaml:ro" \
enterpilot/gomodel:latest
```

With Docker Compose:

```yaml
services:
gomodel:
image: enterpilot/gomodel:latest
ports:
- "8080:8080"
volumes:
- ./config.yml:/app/config/config.yaml:ro
```

<Tip>
If env vars and YAML both define the same setting, the environment variable
wins.
</Tip>
3 changes: 3 additions & 0 deletions docs/advanced/configuration.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,9 @@ For more complex setups, you can use an optional YAML configuration file. GOMode
1. `config/config.yaml`
2. `config.yaml`

If you are deciding whether you need YAML at all, see
[config.yaml](/advanced/config-yaml).

To get started, copy the example:

```bash
Expand Down
3 changes: 2 additions & 1 deletion docs/docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,15 @@
"pages": [
"guides/openclaw",
"guides/oracle",
"guides/multiple-ollama",
"guides/claude-code",
"guides/codex",
"guides/opencode-and-other-agents"
]
},
{
"group": "Advanced",
"pages": ["advanced/configuration", "advanced/guardrails", "advanced/admin-endpoints"]
"pages": ["advanced/configuration", "advanced/config-yaml", "advanced/guardrails", "advanced/admin-endpoints"]
},
{
"group": "About",
Expand Down
85 changes: 85 additions & 0 deletions docs/guides/multiple-ollama.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
title: "Running Multiple Ollama Backends"
description: "Use one GoModel instance with multiple Ollama providers by mounting a YAML config and selecting provider-qualified model IDs."
---

GoModel can register multiple Ollama providers when each one has its own key in
the top-level `providers:` map.

Flow:

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

## 1. Create a host-side `config.yml`

```yaml
providers:
ollama-a:
type: ollama
base_url: "http://host.docker.internal:11434/v1"

ollama-b:
type: ollama
base_url: "http://host.docker.internal:11435/v1"
```

Use different ports or hostnames for each Ollama instance.

## 2. Run GoModel and mount the config

```bash
docker run --rm --name gomodel \
-p 8080:8080 \
-e GOMODEL_MASTER_KEY="change-me" \
-v "$PWD/config.yml:/app/config/config.yaml:ro" \
Comment on lines +33 to +34

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Avoid normalizing weak default auth values in copy-paste commands.

The guide currently uses change-me directly in both server and client examples. Please explicitly require a strong random key and show command examples that reference an env var instead of a literal weak value.

🔐 Suggested doc hardening
+Generate a strong key before running:
+
+```bash
+export GOMODEL_MASTER_KEY="$(openssl rand -hex 32)"
+```
+
 ```bash
 docker run --rm --name gomodel \
   -p 8080:8080 \
-  -e GOMODEL_MASTER_KEY="change-me" \
+  -e GOMODEL_MASTER_KEY="$GOMODEL_MASTER_KEY" \
   -v "$PWD/config.yml:/app/config/config.yaml:ro" \
   enterpilot/gomodel:latest

```diff
 curl -s http://localhost:8080/v1/models \
-  -H "Authorization: Bearer change-me"
+  -H "Authorization: Bearer $GOMODEL_MASTER_KEY"
 curl -s http://localhost:8080/v1/chat/completions \
-  -H "Authorization: Bearer change-me" \
+  -H "Authorization: Bearer $GOMODEL_MASTER_KEY" \
   -H "Content-Type: application/json" \

Also applies to: 53-55, 65-67

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/guides/multiple-ollama.mdx` around lines 33 - 34, Replace the literal
weak value "change-me" used in the docker run examples with a reference to an
environment variable (GOMODEL_MASTER_KEY) and show a short example command to
generate/export a strong key (e.g., using openssl rand -hex 32) so the docs
require a secure secret; update all occurrences where -e
GOMODEL_MASTER_KEY="change-me" appears (including the server and client examples
around the docker run snippets and the related lines noted) to use -e
GOMODEL_MASTER_KEY="$GOMODEL_MASTER_KEY" and add the single-line export example
before the docker commands.

enterpilot/gomodel:latest
```
Comment on lines +31 to +36

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Pin the Docker image to a stable version (or digest).

Using enterpilot/gomodel:latest makes the guide non-reproducible and can silently break over time.

📌 Suggested doc update
-docker run --rm --name gomodel \
+docker run --rm --name gomodel \
   -p 8080:8080 \
   -e GOMODEL_MASTER_KEY="change-me" \
   -v "$PWD/config.yml:/app/config/config.yaml:ro" \
-  enterpilot/gomodel:latest
+  enterpilot/gomodel:<pinned-version>
-- `enterpilot/gomodel:latest`
+- `enterpilot/gomodel:<pinned-version>`

Also applies to: 81-81

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docs/guides/multiple-ollama.mdx` around lines 31 - 36, Replace the unpinned
Docker image reference used in the docker run command
(enterpilot/gomodel:latest) with a stable, pinned tag or digest (e.g.,
enterpilot/gomodel:<version> or enterpilot/gomodel@sha256:<digest>) so the
example in the docker run invocation remains reproducible; update the command
sample where enterpilot/gomodel:latest appears and add a brief note recommending
pinning to a version or digest for stability.


<Note>
The file can be named `config.yml` on the host. The important part is the
bind mount target: GoModel reads `/app/config/config.yaml` inside the
container.
</Note>

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

## 3. Verify the model registry

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

## 4. Route to a specific Ollama backend

```bash
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`.

## Validated on April 6, 2026

This guide was validated with:

- `enterpilot/gomodel:latest`
- a bind-mounted host `config.yml`
- two Ollama-compatible upstream endpoints exposed as separate provider names
Loading