# Open WebUI ConfigVar Cheat Sheet

Open WebUI persists connection settings in `webui.db` → `config` table as `ConfigVar` values. After first launch, env vars are **ignored** — the DB is authoritative. Changing `-e OPENAI_API_BASE_URL=...` and restarting does nothing.

## Config Table Schema

The `config` table is key-value with JSON values:
```sql
SELECT key, value FROM config WHERE key LIKE '%ollama%' OR key LIKE '%openai%';
```

## Connection Keys (as of Jul 2026)

### Ollama Connection
| Key | Type | Example |
|-----|------|---------|
| `ollama.enable` | bool | `true` / `false` |
| `ollama.base_urls` | JSON array | `["http://ollama:11434"]` |
| `ollama.api_configs` | JSON object | `{"0": {"enable": true, "tags": [], "prefix_id": "", "model_ids": [], "connection_type": "local", "auth_type": "bearer", "key": ""}}` |

### OpenAI Connection (used for admin-ai / LiteLLM)
| Key | Type | Example |
|-----|------|---------|
| `openai.enable` | bool | `true` / `false` |
| `openai.api_base_urls` | JSON array | `["https://admin-ai.itpropartner.com/v1"]` |
| `openai.api_keys` | JSON array | `["sk-lg_..."]` |
| `openai.api_configs` | JSON object | `{"0": {"enable": true, "tags": [], "prefix_id": "", "model_ids": [], "connection_type": "external", "auth_type": "bearer"}}` |

### RAG / Embeddings
| Key | Type | Example |
|-----|------|---------|
| `rag.ollama.base_url` | string | `"http://host.docker.internal:11434"` |
| `rag.ollama.api_key` | string | `""` |
| `rag.openai.api_base_url` | string | `"http://litellm:4000/v1"` |
| `rag.openai.api_key` | string | `"sk-..."` |

### Audio (TTS/STT)
| Key | Type | Example |
|-----|------|---------|
| `audio.tts.openai.api_base_url` | string | `"http://litellm:4000/v1"` |
| `audio.tts.openai.api_key` | string | `"sk-..."` |
| `audio.stt.openai.api_base_url` | string | `"http://litellm:4000/v1"` |
| `audio.stt.openai.api_key` | string | `"sk-..."` |

### Image Generation
| Key | Type | Example |
|-----|------|---------|
| `image_generation.openai.api_base_url` | string | `"http://127.0.0.0:4000/v1"` |
| `image_generation.openai.api_key` | string | `"sk-..."` |

## Common Operations

### Disable Ollama (stop pointing to Ollama)
```bash
sqlite3 /var/lib/docker/volumes/openwebui_data/_data/webui.db \
  "UPDATE config SET value = 'false' WHERE key = 'ollama.enable';"
sqlite3 /var/lib/docker/volumes/openwebui_data/_data/webui.db \
  "UPDATE config SET value = json_set(value, '\$.\"0\".enable', json('false')) WHERE key = 'ollama.api_configs';"
docker restart openwebui
```

### Change OpenAI base URL (switch admin-ai endpoint)
```bash
sqlite3 /var/lib/docker/volumes/openwebui_data/_data/webui.db \
  "UPDATE config SET value = json_set(value, '\$[0]', 'https://new-url/v1') WHERE key = 'openai.api_base_urls';"
docker restart openwebui
```

### Verify changes took effect
```bash
sqlite3 /var/lib/docker/volumes/openwebui_data/_data/webui.db \
  "SELECT key, value FROM config WHERE key IN ('ollama.enable', 'openai.api_base_urls', 'ollama.api_configs');"
```

### Full audit — dump all connection-related config
```bash
sqlite3 /var/lib/docker/volumes/openwebui_data/_data/webui.db \
  "SELECT key, value FROM config WHERE key LIKE '%ollama%' OR key LIKE '%openai%' ORDER BY key;"
```

## Pitfalls

- **`OLLAMA_BASE_URL=/ollama` is baked into the image** — omitting the env var doesn't clear it; the image default applies. After first launch, it's persisted in `ollama.base_urls` in the DB.
- **`ENABLE_PERSISTENT_CONFIG=false` disables ALL UI settings persistence** — use only for one-off fixes, not as permanent config.
- **The container image doesn't include `sqlite3`** — install on the host: `apt-get install -y sqlite3`.
- **After DB changes, `docker restart` is required** — the config is read at startup.
- **JSON path syntax is strict** — `\$.\"0\".enable` for object keys that start with digits (SQLite's `json_set` requires double-quoted keys for numeric-looking keys).
