# Configuration

## Environment Variables

All configuration is done via environment variables. Create a `.env` file in the project root.

### Access Control

| Variable                   | Default | Description                                                                                 |
| -------------------------- | ------- | ------------------------------------------------------------------------------------------- |
| `ACCESS_KEYS`              | `''`    | Comma-separated list of valid access keys (e.g., `'key1,key2,key3'`)                        |
| `ACCESS_KEY_TIMEOUT_HOURS` | `24`    | Hours to cache validated keys in browser. Set to `0` to require validation on every request |

**Example:**

```bash
ACCESS_KEYS="my-secret-key-1,my-secret-key-2"
ACCESS_KEY_TIMEOUT_HOURS="24"
```

### AI Model Defaults

Configure default models for different inference types:

| Variable                      | Default           | Description                                                                                   |
| ----------------------------- | ----------------- | --------------------------------------------------------------------------------------------- |
| `WLLAMA_DEFAULT_MODEL_ID`     | `littlelamb-290m` | Default Wllama model ID for browsers without WebGPU, where the model runs on the CPU          |
| `WLLAMA_DEFAULT_GPU_MODEL_ID` | `gemma-3-4b`      | Default Wllama model ID for browsers with WebGPU. It does not fall back to the variable above |

Both only seed a profile that has never saved settings; a user's own choice always wins. A page load where the server configuration could not be fetched saves nothing, so a first-time profile is still seeded on a later load. Detection is the same check that decides whether the model runs on the GPU: the browser must have WebGPU, and its GPU must be able to run wllama's shaders (`client/modules/webGpu.ts`, described in [ai-integration.md](ai-integration.md)).

### Server Model Request Configuration

These apply to the Internal API's requests (`/inference`). Each takes a whole
number written in digits. An empty value uses the default; any other value
(`8k`, `1e4`, `0`, or a timeout above 2147483647, the longest a Node timer can
wait) is logged once and replaced by the default.

| Variable                   | Default | Description                                                      |
| -------------------------- | ------- | ---------------------------------------------------------------- |
| `MODEL_REQUEST_TIMEOUT_MS` | `30000` | How long the API may stay silent before the attempt is abandoned |
| `MODEL_DEFAULT_MAX_TOKENS` | `8192`  | Upper bound on the `max_tokens` a request may ask for            |

All Internal API variables, these two included, are read in one place:
`server/internalApiConfig.ts`.

### Internal API Configuration

For self-hosted OpenAI-compatible APIs:

| Variable                                          | Default        | Description                                                        |
| ------------------------------------------------- | -------------- | ------------------------------------------------------------------ |
| `INTERNAL_OPENAI_COMPATIBLE_API_BASE_URL`         | `''`           | Base URL of your API (e.g., `https://api.internal.company.com/v1`) |
| `INTERNAL_OPENAI_COMPATIBLE_API_KEY`              | `''`           | API key for authentication                                         |
| `INTERNAL_OPENAI_COMPATIBLE_API_MODEL`            | `''`           | Model ID, or a comma-separated list (random model if empty)        |
| `INTERNAL_OPENAI_COMPATIBLE_API_CONTEXT_LENGTH`   | `131072`       | Context window of the API's models, in tokens                      |
| `INTERNAL_OPENAI_COMPATIBLE_API_REASONING_EFFORT` | `''`           | Sent as `reasoning_effort` on every request (API default if empty) |
| `INTERNAL_OPENAI_COMPATIBLE_API_NAME`             | `Internal API` | Display name shown in UI                                           |

**Example:**

```bash
INTERNAL_OPENAI_COMPATIBLE_API_BASE_URL="https://llm.internal.company.com/v1"
INTERNAL_OPENAI_COMPATIBLE_API_KEY="sk-internal-xxx"
INTERNAL_OPENAI_COMPATIBLE_API_MODEL="llama-3.1-8b"
INTERNAL_OPENAI_COMPATIBLE_API_NAME="Company LLM"
```

`INTERNAL_OPENAI_COMPATIBLE_API_MODEL` takes several models, separated by commas, in order of preference (`"llama-3.1-8b,qwen-3-8b"`). When a model fails before sending the first token, the server moves to the next one, and after the last one it starts the list over once, up to 5 attempts in all. So a single model gets one retry. Left empty, each request picks a random model from the API's `/models` list, which includes every model the API serves.

`INTERNAL_OPENAI_COMPATIBLE_API_CONTEXT_LENGTH` is the window the browser sizes the request from: the page excerpts get 35% of it, and the answer's `max_tokens` is what is left after the prompt. The server then caps `max_tokens` at `MODEL_DEFAULT_MAX_TOKENS` (8192), which on most OpenAI-compatible APIs also has to hold the thinking of a reasoning model. Set it lower when the models have a smaller window, or the API rejects the longer prompts. A value that is not a whole number written in digits is logged once and replaced by the default.

`INTERNAL_OPENAI_COMPATIBLE_API_REASONING_EFFORT` sets the `reasoning_effort` field of every request to the API, for every model in the list. The value is passed through as written, because providers accept different values (`none`, `minimal`, `low`, `medium`, `high`, `xhigh`); one the API rejects fails the request, and the error shows in the server log. Left empty, the field is not sent and the API applies its own default.

### Default Behavior

| Variable                 | Default   | Description                                                          |
| ------------------------ | --------- | -------------------------------------------------------------------- |
| `DEFAULT_INFERENCE_TYPE` | `browser` | Default AI inference type (`browser`, `openai`, `horde`, `internal`) |

### Embedding

When MiniSearch runs inside an iframe, it posts each search to the embedding page as `{ queryString, hash: "" }`, so a page such as a Hugging Face Space can keep its own address in sync with the search.

| Variable                | Default                  | Description                                                                                                                                                                                                  |
| ----------------------- | ------------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `PARENT_WINDOW_ORIGINS` | `https://huggingface.co` | Comma-separated list of the origins allowed to receive the query. It is posted to each one, and the browser delivers it only when the embedding page is on that origin. Set it empty to never post the query |

An origin is the scheme, host and port, with no path (`https://example.com`, `http://localhost:8080`). The query is never posted to `*`, since any site can frame an instance.

### Server Configuration

These variables control the Vite development/preview server behavior:

| Variable        | Default   | Description                                                                                                                                                                                                                                                                       |
| --------------- | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `HOST`          | `0.0.0.0` | Host address for the Vite server to bind to                                                                                                                                                                                                                                       |
| `PORT`          | `7860`    | Port number for the main server                                                                                                                                                                                                                                                   |
| `HMR_PORT`      | `7861`    | Port for Hot Module Replacement during development                                                                                                                                                                                                                                |
| `ALLOWED_HOSTS` | `true`    | Comma-separated list of allowed hostnames for the preview server                                                                                                                                                                                                                  |
| `BASIC_SSL`     | `false`   | Enable basic SSL for HTTPS support during development                                                                                                                                                                                                                             |
| `TRUST_PROXY`   | `false`   | Trust `X-Forwarded-For`/`X-Real-IP` for the per-client rate-limit key. Enable **only** behind a reverse proxy that sets the rightmost `X-Forwarded-For` entry. Leave off when the instance is exposed directly - otherwise clients could forge the header to evade rate limiting. |

These defaults are provided by `docker-compose.yml`/`docker-compose.production.yml` (e.g. `PORT=${PORT:-7860}`), not by the application itself - `vite.config.ts` reads these variables with no fallback, so when running directly via `npm run dev`/`vite preview` without Docker, unset variables fall through to Vite's own built-in defaults, except `ALLOWED_HOSTS`, which allows any host when unset. In the comma-separated lists (`ACCESS_KEYS` and `ALLOWED_HOSTS`), spaces around an entry and empty entries are ignored.

### Search Fallback

When SearXNG fails on a text search, the server can retry that search against second providers: `search.parallel.ai` (Parallel), You.com's MCP endpoint (`https://api.you.com/mcp`), and Keenable's MCP endpoint (`https://api.keenable.ai/mcp`). Every configured provider takes part. On each search they are put in a random order, and each is tried in turn until one returns results; a provider that answers with nothing usable, or fails, hands the search to the next one. The whole cascade shares one 15-second budget, and each attempt gets the remaining budget divided by the number of providers still untried and not paused, so a provider that hangs cannot use up the time the others need. A single search can therefore reach more than one provider, one after the other. `docker-compose.yml` passes only `HOST`, `PORT`, `BASIC_SSL` and `HMR_PORT` into the development container, so these variables are not carried by the compose `environment` list; set them in `.env`, which `vite.config.ts` loads, inside the container as well as outside it. `vite.config.ts` reads `.env.example` after `.env`, so anything still set there acts as a default: the real API keys belong in `.env`, never in `.env.example`, which is committed.

| Variable                           | Default              | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                              |
| ---------------------------------- | -------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `SEARCH_FALLBACK_ENABLED`          | `false`              | Serve text results from the fallback providers when SearXNG has failed (an HTTP error, a network error, every engine unresponsive, or an open circuit), under one 15-second budget for the whole cascade. Only `true` or `1` turns it on, and changing it takes a restart, since a process keeps the environment it was started with. Image searches never use it, and a fallback that returns nothing usable is still an HTTP 200 with no results rather than an outage |
| `SEARCH_FALLBACK_PROVIDERS`        | `''` (all providers) | Comma-separated list of the providers to try: `parallel`, `youcom`, `keenable`, or any mix. Names are trimmed and lowercased, and empty items are ignored. Unset or empty means all three: Parallel, You.com and Keenable. With `SEARCH_FALLBACK_ENABLED` on, an unknown name, or a list with no names at all (such as `,`), stops the server at start with an error that names the valid values                                                                         |
| `SEARCH_FALLBACK_PARALLEL_API_KEY` | `''`                 | Optional API key for Parallel, sent as a Bearer token. Without it the fallback calls Parallel's keyless tier. With `SEARCH_FALLBACK_ENABLED` on, a key with a control character inside it (such as a pasted line break) stops the server at start, since the HTTP client would quote it in its error                                                                                                                                                                     |
| `SEARCH_FALLBACK_YOUCOM_API_KEY`   | `''`                 | Optional API key for You.com, sent as a Bearer token. Without it the fallback calls the keyless `https://api.you.com/mcp?profile=free` endpoint. A key with a control character inside it stops the server at start, like the Parallel key                                                                                                                                                                                                                               |
| `SEARCH_FALLBACK_KEENABLE_API_KEY` | `''`                 | Optional API key for Keenable, sent as `X-API-Key` to `https://api.keenable.ai/mcp`. Without it Keenable uses the keyless `https://api.keenable.ai/mcp-public` endpoint, like the other keyless tiers. Every request names the app in `X-Keenable-Title: MiniSearch`. A key with a control character inside it stops the server at start, like the other keys                                                                                                            |

`SEARCH_FALLBACK_PROVIDER` and `SEARCH_FALLBACK_API_KEY` are gone. If either is still set to a non-empty value while `SEARCH_FALLBACK_ENABLED` is on, the server stops at start with an error that names the variable to use instead, so an upgrade cannot silently drop a key: move the key to `SEARCH_FALLBACK_PARALLEL_API_KEY` or `SEARCH_FALLBACK_YOUCOM_API_KEY`, and the provider choice to `SEARCH_FALLBACK_PROVIDERS`.

Each provider has its own terms, and each operator is responsible for following them:

- **Parallel**: Parallel describes its keyless tier as for exploration and light use, and asks for an account and an API key for production use ([docs.parallel.ai](https://docs.parallel.ai/integrations/mcp/search-mcp)).
- **You.com**: the keyless `profile=free` endpoint allows 100 queries per day ([you.com](https://you.com/docs/build-with-agents/mcp-server)). Its API acceptable use policy asks integrations to honor 429 responses ([you.com](https://you.com/acceptable-use-policy-may-2026)).
- **Keenable**: the keyless endpoint allows 1,000 requests an hour and 10 a second per IP address ([docs.keenable.ai](https://docs.keenable.ai/guides/keyless-access)). Keenable logs requests with or without a key on its default data policy ([docs.keenable.ai](https://docs.keenable.ai/data-privacy)).

That is why a provider that answers HTTP 429 is paused: the cascade skips it, without a network call, until its `Retry-After` has passed (60 seconds when the header is missing or invalid, and never more than an hour or less than a second). A public instance should set a key for each provider.

### Official Page Lane

A search that asks for an official page can miss the official site: an engine answering "disney 下个月排片" with aggregators and fan blogs leaves the schedule page out of the set entirely, and no ranking of that set can recover it. With the lane on, when the query carries navigation intent and one of the returned results names a site, the server asks SearXNG a second, `site:`-scoped question and merges the answers before ranking. `docs/reranking.md` records the rule; this variable governs it.

| Variable                       | Default | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| ------------------------------ | ------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `SEARCH_OFFICIAL_LANE_ENABLED` | `false` | Run the second, `site:`-scoped search when the query asks for an official page. Only `true` or `1` turns it on, and changing it takes a restart, since a process keeps the environment it was started with. It is off by default because it sends the engines a second request, which an instance they already rate-limit cannot afford. The lane runs only when SearXNG served the search (never after the fallback), never uses the last five seconds of the search deadline, and is canceled at eight seconds. It is one request with no retry, and its failures count toward neither the SearXNG circuit nor the engine health in `/status`: a failure only logs and is counted under `searches.officialLane`, never turning a served search into a 502. SearXNG still sees the extra request, so an engine that suspends the instance after a CAPTCHA does so for every search |

## Application Settings

Settings are stored in browser localStorage and can be changed via the Settings UI.

### Core Settings

| Setting                          | Type    | Default    | Description                                                                                             |
| -------------------------------- | ------- | ---------- | ------------------------------------------------------------------------------------------------------- |
| `enableAiResponse`               | boolean | `false`    | Enable AI-generated responses for searches                                                              |
| `showEnableAiResponsePrompt`     | boolean | `true`     | Show prompt to enable AI response on first use                                                          |
| `enableImageSearch`              | boolean | `true`     | Include image results in searches                                                                       |
| `enableTextSearch`               | boolean | `true`     | Include text results in searches                                                                        |
| `searchResultsLimit`             | number  | `15`       | Maximum search results to fetch                                                                         |
| `searchTimeRange`                | string  | `any`      | Only return results published within this period: `any`, `day`, `week`, `month` or `year`               |
| `systemPrompt`                   | string  | (template) | Custom system prompt template for AI                                                                    |
| `enterToSubmit`                  | boolean | `true`     | Press Enter to submit query (vs Shift+Enter for new line)                                               |
| `enableAiResponseScrolling`      | boolean | `true`     | Auto-scroll AI response as it generates                                                                 |
| `enableNotificationOnAiComplete` | boolean | `false`    | Show a browser notification when AI response generation finishes                                        |
| `enablePageContentFetch`         | boolean | `true`     | Read the pages behind the top results and ground the answer on their text instead of on snippets alone. |

### Inference Settings

| Setting                | Type    | Default                           | Description                                                                                                                            |
| ---------------------- | ------- | --------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------- |
| `inferenceType`        | enum    | `'browser'`                       | AI provider: `browser`, `openai`, `horde`, `internal`                                                                                  |
| `cpuThreads`           | number  | (auto)                            | Number of CPU threads for inference (Wllama), defaults to half the logical processors (`navigator.hardwareConcurrency / 2`), minimum 1 |
| `allowAiModelDownload` | boolean | `false`                           | Allow automatic AI model downloads                                                                                                     |
| `wllamaModelId`        | string  | WebGPU or CPU default, see above. | Default Wllama model ID, chosen by whether the browser has WebGPU                                                                      |
| `hordeApiKey`          | string  | `'0000000000'`                    | AI Horde API key (default is anonymous)                                                                                                |
| `hordeModel`           | string  | `''`                              | Specific AI Horde model to request; empty asks for the five most requested models this month                                           |
| `openAiApiBaseUrl`     | string  | `''`                              | Base URL for the OpenAI-compatible API                                                                                                 |
| `openAiApiKey`         | string  | `''`                              | API key for the OpenAI-compatible API                                                                                                  |
| `openAiApiModel`       | string  | `''`                              | Model identifier for the OpenAI-compatible API                                                                                         |
| `openAiContextLength`  | number  | `4096`                            | Context window size for OpenAI-compatible models; `max_tokens` is what is left of it after the prompt (at least 64)                    |

### Model Selection

**Wllama Models:**

- Several pre-configured models, listed in `client/modules/wllama.ts`
- All quantized to a Q3/Q4-class quant (Q4_K_S, Q4_K_M, Q3_K_S, UD-Q3_K_XL or UD-Q4_K_XL)
- Stored on HuggingFace: a model under 2000 MiB can be a single GGUF from its original repo, a bigger one is sharded in a `Felladrin/gguf-sharded-*` repo

**OpenAI/Internal:**

- Any OpenAI-compatible API
- Auto-model detection if not specified
- Supports streaming and reasoning models

**AI Horde:**

- Uses aihorde.net distributed network
- Anonymous or authenticated access
- Parallel generation with race conditions

### History Settings

| Setting                | Type    | Default | Description                             |
| ---------------------- | ------- | ------- | --------------------------------------- |
| `enableHistory`        | boolean | `true`  | Enable search history persistence       |
| `historyRetentionDays` | number  | `30`    | Days to keep search history             |
| `historyMaxEntries`    | number  | `1000`  | Maximum history entries before cleanup  |
| `historyAutoCleanup`   | boolean | `true`  | Automatically clean old history entries |
| `historyGroupByDate`   | boolean | `true`  | Group history entries by date in UI     |

### System Prompt Configuration

The default system prompt supports template placeholders populated at runtime:

```typescript
{
  systemPrompt: `Answer the question using the search results below. Reply in the same language as the question.

Cite each fact with a Markdown link right after it, using the site's domain as the link text. Example: [example.com](https://example.com/page).

If you answer from your own knowledge because the results do not cover it, say so.

Use only these Markdown elements: link, bold, italic, code, quote, table.

Today's date is {{currentDate}}. Use it for relative dates such as "yesterday".

Search results:

{{searchResults}}`,
  reasoningStartMarker: '<think>',
  reasoningEndMarker: '</think>'
}
```

**Placeholders:**

- `{{currentDate}}`: Current date injected at generation time
- `{{dateTime}}`: Alias for `{{currentDate}}` - both are replaced with the same current date value
- `{{searchResults}}`: Formatted search results from the web search, including the page excerpts when `enablePageContentFetch` is on

**Reasoning Markers:** Models that output internal thought processes use `<think>` and `</think>` markers. The UI extracts and separately displays reasoning content from the final response. Browser (Wllama) thinking models are wrapped in these markers automatically, so their chain of thought shows up the same way.

### Privacy Settings

| Setting                     | Type                  | Default      | Description                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| --------------------------- | --------------------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `selectedVoiceId`           | string                | `""`         | Voice for reading answers aloud. `piper:<voice>` picks a local neural voice, `system:<voiceURI>` an OS voice, and `""` picks one automatically for the language of each answer (see [ai-integration.md](ai-integration.md#voices)). The Voice settings panel lists only the voices of the selected engine, the local ones in every language, and switching that engine resets this to `""`. A bare value stored by an earlier version is read as an OS voice whenever the system engine runs; with the local engine it is ignored in favor of a language match                                                                                                                                                                                                                                                                                                                                        |
| `textToSpeechEngine`        | `"local" \| "system"` | `"local"`    | Which engine reads answers aloud, and which set of voices the Voice settings panel lists. `"system"` also overrides a local voice picked above, and stops the voice list from being fetched, so it never contacts a third-party host. A profile that had picked an OS voice before this setting existed starts on `"system"`, so the upgrade does not replace that choice with a model download                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       |
| `enableDictation`           | boolean               | `true`       | Shows the microphone button inside the search field and the chat follow-up field, which fills whichever one it sits in while the user speaks. Turning this off hides the button and loads nothing. The button is also hidden outside a secure context, so an instance served over plain HTTP on a LAN will not show it: no browser grants microphone access there                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     |
| `enableLocalDictationModel` | boolean               | `true`       | Whether the dictation button prefers the on-device Qwen3-ASR model, which transcribes many languages without the audio leaving the device. The first press downloads ~700 MB from Hugging Face, and later presses load it from the browser's storage. The model writes the text once the recording stops, and a recording ends on its own after two minutes. With this off, the button uses the browser's built-in `SpeechRecognition`, which shows the text while the user speaks but may send the audio to the browser vendor. The preference reorders the two engines and never removes one: on browsers without `SpeechRecognition` the on-device model is used regardless. Until the model became multilingual, the default was `true` only for an English browser, and a profile saved back then keeps its stored value, so the Voice settings panel is where a non-English profile turns it on |
| `reasoningStartMarker`      | string                | `"<think>"`  | Marker for start of reasoning content                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                 |
| `reasoningEndMarker`        | string                | `"</think>"` | Marker for end of reasoning content                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   |

## Docker Configuration

### docker-compose.yml (Development)

```yaml
services:
  development-server:
    environment:
      - HOST=${HOST:-0.0.0.0}
      - PORT=${PORT:-7860}
      - BASIC_SSL=${BASIC_SSL:-false}
      - HMR_PORT=${HMR_PORT:-7861}
    ports:
      - "${PORT:-7860}:7860"
      - "${HMR_PORT:-7861}:7861"
    build:
      dockerfile: Dockerfile
      context: .
    volumes:
      - .:/home/node/app/ # Live code mounting
    command:
      [
        "(cd /usr/local/searxng/searxng-src && /usr/local/searxng/searxng-venv/bin/python -m searx.webapp > /tmp/searxng.log 2>&1) & (npm install && npm run dev)",
      ]
```

### docker-compose.production.yml

Same structure but without volume mounts and with pre-built assets.

### Dockerfile Environment

The Dockerfile sets up a single runtime stage:

- Node.js LTS
- Python 3 + SearXNG

The app runs under the `node` user, with the app directory at `/home/node/app`. The production image starts the app with `npm start -- --host` (i.e. `vite preview`), not `npm run dev`.

**Multi-service container** runs SearXNG and Node.js concurrently via shell process composition.

### Nothing Is Configured at Build Time

The Dockerfile declares no `ARG` for any of the settings above, and
`.dockerignore` excludes `.env` files from the build context. Both are
deliberate: build args are recorded in `docker history`, and a copied `.env`
becomes a readable image layer, so either one would publish `ACCESS_KEYS` and
`INTERNAL_OPENAI_COMPATIBLE_API_KEY` to anyone who pulls the image.

Pass configuration when you start the container, via `docker run -e`, the
`environment:` block in a compose file, or a secret manager. Building your own
image with `--build-arg ACCESS_KEYS=...` has no effect, and neither does
relying on a local `.env` being baked in; without runtime values the app falls
back to the `.env.example` defaults. See
[Runtime Configuration](#runtime-configuration) for how those values reach the
client.

## Tuning the Search Engines

The bundled SearXNG instance decides which engines answer a query. MiniSearch ships a thin overlay for it (`searxng-settings.yml`) that declares three things: the JSON output format that `server/webSearchService.ts` consumes, a `secret_key` that the Dockerfile rewrites with a random value at build time, and Mojeek switched on for text search. Everything else about the engine list comes from the pinned SearXNG build, so read the set from the running instance rather than from this page: the command below shows which engines answered and which came back unresponsive. Whatever that set turns out to be, one engine that is rate-limited or CAPTCHA-challenged from your server's IP thins every result page, because the other engines have to carry the query on their own.

Diagnose before you change anything. `/status` needs no token and publishes `searches.unresponsiveEngines`, each engine classified `blocked`, `timeout` or `other`, and the server log prints the same names through the always-on `debug` in `server/webSearchService.ts`. See [Debugging Configuration](#debugging-configuration). To see the engine set itself, ask SearXNG directly, with the same parameters the app sends:

```bash
docker exec <container> /usr/local/searxng/searxng-venv/bin/python -c "
import json, urllib.request
from collections import Counter
url = ('http://127.0.0.1:8888/search?q=hiking+near+lisbon&format=json'
       '&categories=general&lang=auto&safesearch=1')
data = json.load(urllib.request.urlopen(url, timeout=60))
print(len(data.get('results', [])), dict(Counter(r.get('engine') for r in data.get('results', []))))
print('unresponsive:', data.get('unresponsive_engines'))
"
```

Image search asks for `categories=images,videos` instead, and the same switches below apply to the image engines.

SearXNG reads its settings when the container starts, so you can replace that file without rebuilding the image. It looks at `SEARXNG_SETTINGS_PATH` first and at `/etc/searxng/settings.yml` otherwise. A `SEARXNG_SETTINGS_PATH` that points at a file which is not there is a hard failure rather than a fallthrough: SearXNG exits with `EnvironmentError: <path> not exists!`. Prefer that variable, because it leaves the image's own file untouched and lets your file be mounted read-only.

The name is also a build `ARG` in the Dockerfile, where it only selects where the overlay is copied. A build arg does not survive into the container environment, so `--build-arg SEARXNG_SETTINGS_PATH=...` changes nothing at runtime; it only picks where the overlay is copied during the build.

Two switches turn engines on, and they are not interchangeable: `disabled: false` is for an engine that ships `disabled: true`, and `inactive: false` is for one that ships `inactive: true`. Which one a given engine needs is written in the pinned upstream settings file inside the container:

```bash
docker exec <container> grep -A8 -E '^  - name: (mojeek|startpage|google)$' /usr/local/searxng/searxng-src/searx/settings.yml
```

Setting the other one fails silently. An engine left `inactive` is never loaded, and one left `disabled` is loaded but never queried, so it simply never shows up in results and nothing reports why. Both switches were measured against the published image: with `google` set to `disabled: false` it contributed 10 of the results in that run, and with `mojeek` set to `inactive: false` it contributed 9 in another. The run totals are further down this section.

```yaml
# my-searxng-settings.yml
use_default_settings: true

server:
  secret_key: "<your own random value>"

search:
  formats:
    - json

engines:
  - name: mojeek
    inactive: false
  - name: google
    disabled: false
```

`use_default_settings: true` keeps the upstream engine list and merges your entries into it by engine name, and `search.formats: [json]` must stay, because it is how MiniSearch reads the response. The full vocabulary is in the [SearXNG settings docs](https://docs.searxng.org/admin/settings/settings.html).

```bash
docker run -p 7860:7860 \
  -e SEARXNG_SETTINGS_PATH=/etc/searxng-custom/settings.yml \
  -v "$(pwd)/my-searxng-settings.yml:/etc/searxng-custom/settings.yml:ro" \
  ghcr.io/felladrin/minisearch
```

The compose equivalent:

```yaml
services:
  minisearch:
    image: ghcr.io/felladrin/minisearch:latest
    ports:
      - "7860:7860"
    environment:
      - SEARXNG_SETTINGS_PATH=/etc/searxng-custom/settings.yml
    volumes:
      - ./my-searxng-settings.yml:/etc/searxng-custom/settings.yml:ro
```

Two things about that command are required, not optional:

- **The file must be readable by uid 1000.** The container runs as `node`, and a file readable only by its owner on the host is invisible to it.
- **`secret_key` must be set to your own random value.** SearXNG refuses to start on the `ultrasecretkey` placeholder and logs `server.secret_key is not changed. Please use something else instead of ultrasecretkey.` The image's own file never carries the placeholder, because the Dockerfile replaces it at build time, but a file you write has to carry a real key.

A SearXNG startup failure will not show in `docker logs`. The container's CMD sends SearXNG's output to `/dev/null`, deliberately, so that the app server's log stays clean. To see it, run SearXNG in the foreground inside the container, which is only possible once the original has failed: on a running instance the second process collides with the live one on `127.0.0.1:8888` and reports the address as already in use.

```bash
docker exec <container> sh -c 'cd /usr/local/searxng/searxng-src && /usr/local/searxng/searxng-venv/bin/python -m searx.webapp'
```

To check the override took effect, print the flags of the engines you changed. Printing the names proves nothing, because every engine name is in the upstream list whether or not your entry was applied:

```bash
docker exec <container> /usr/local/searxng/searxng-venv/bin/python -c "
import searx.settings_loader as sl
settings, source = sl.load_settings()
print(source)
print([(e['name'], e.get('disabled'), e.get('inactive'))
       for e in settings['engines'] if e['name'] in ('mojeek', 'google')])
"
```

Then run the query command from the top of this section again and compare which engines answered. In a run against the published image on 2026-09-22, the default settings returned 24 results for one query, all from `brave`, with `duckduckgo` reported CAPTCHA and `google cse` reported as crashed. The same query with `mojeek` switched on returned 42 results across `brave`, `mojeek` and `google cse`, and a third run with `google` switched on returned 40 across `google`, `brave` and `google cse`. Treat those as measurements of one host on one day: which engines answer depends on your IP and on the hour, and `google cse` came back on its own between the first run and the second.

Engine choice does not change the privacy posture. SearXNG still makes the request, from your server's address, so the engine sees the instance and not the user, and no query goes to any third party that SearXNG did not already talk to.

None of this reaches MiniSearch's code. The app asks SearXNG for one JSON document and reranks whatever comes back, so nothing in `server/webSearchService.ts` changes when you retune the engines, and the circuit breaker, the retries and the `unresponsive_engines` reporting keep working over the new set.

### Why the image switches Mojeek on

Since the SearXNG commit pinned on 2026-11-23, upstream ships the Brave web engine disabled (its result links went through a redirect), which leaves DuckDuckGo and Google CSE as the only general web engines on by default, plus Wikipedia and Wikidata, which added no result in the run below. DuckDuckGo answers a CAPTCHA to many server addresses. On the public instance, in the days before that update, Brave, DuckDuckGo and Google CSE were all blocked at once on 219 of 371 text searches (59%), which sent those searches to the fallback providers. Mojeek runs its own index and is switched on in the bundled overlay. In a run of the image on 2026-11-23 (10 queries, 8 seconds apart, from a residential address), Mojeek returned 10 results on every query, while DuckDuckGo answered a CAPTCHA on 2 of the 10. In a second run of 5 queries, 7 to 9 of Mojeek's results per query came from no other engine. Qwant was tried in the same run and refused the first query with `access denied`, so it stays off.

## Runtime Configuration

Client-facing configuration (access keys, inference type, internal API settings) is resolved at runtime via the `/api/config` endpoint. The client fetches this endpoint on app initialization, so the published Docker image is fully configurable via environment variables at runtime - no rebuild needed.

### `/api/config` Response

```json
{
  "accessKeysEnabled": true,
  "accessKeyTimeoutHours": 24,
  "wllamaDefaultModelId": "littlelamb-290m",
  "wllamaDefaultGpuModelId": "gemma-3-4b",
  "internalApiEnabled": true,
  "internalApiName": "Internal API",
  "defaultInferenceType": "browser",
  "searchToken": "<search-token>",
  "parentWindowOrigins": ["https://huggingface.co"]
}
```

### Build-Time vs Runtime Configuration

| Value                              | Resolved At | Notes                                                                                                                                                                   |
| ---------------------------------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `VITE_BUILD_DATE_TIME`             | Build time  | Epoch milliseconds when the build occurred                                                                                                                              |
| `VITE_COMMIT_SHORT_HASH`           | Build time  | The commit the build reports: the source commit the Hugging Face deploy workflow wrote into `.source-commit`, or, when that file is not there, the build's own git hash |
| `ACCESS_KEYS`                      | Runtime     | Read from `/api/config`                                                                                                                                                 |
| `ACCESS_KEY_TIMEOUT_HOURS`         | Runtime     | Read from `/api/config`                                                                                                                                                 |
| `WLLAMA_DEFAULT_MODEL_ID`          | Runtime     | Read from `/api/config`                                                                                                                                                 |
| `WLLAMA_DEFAULT_GPU_MODEL_ID`      | Runtime     | Read from `/api/config`                                                                                                                                                 |
| `INTERNAL_OPENAI_COMPATIBLE_API_*` | Runtime     | Read from `/api/config` (except `API_KEY` which is server-only)                                                                                                         |
| `DEFAULT_INFERENCE_TYPE`           | Runtime     | Read from `/api/config`                                                                                                                                                 |
| `PARENT_WINDOW_ORIGINS`            | Runtime     | Read from `/api/config`                                                                                                                                                 |
| Search token                       | Runtime     | Read from `/api/config`, so a reload picks up the token of whichever server answers                                                                                     |

### Security Considerations

- `VITE_BUILD_DATE_TIME` and `VITE_COMMIT_SHORT_HASH` are bundled into the client JavaScript as build-time constants (build metadata only). A Hugging Face Space is built from a copy of the repository, so its git hash belongs to the Space; the deploy workflow writes the source commit into `.source-commit` beside that copy, and `shared/buildSourceCommit.ts` prefers it, which is what `/status` and the app version string then report
- The CSRF token is served at runtime like the rest of the config. It reaches any caller that can reach `/api/config`, which is the same exposure it had while it was compiled into the bundle
- All other configuration is fetched at runtime from `/api/config` and never appears in the bundled JavaScript
- Server-only variables like `INTERNAL_OPENAI_COMPATIBLE_API_KEY` are never exposed to the client

## Configuration Patterns

### Scenario: Private Team Instance

```bash
# .env
ACCESS_KEYS="team-alpha-2024,team-beta-2024"
ACCESS_KEY_TIMEOUT_HOURS="8"
DEFAULT_INFERENCE_TYPE="internal"
INTERNAL_OPENAI_COMPATIBLE_API_BASE_URL="https://llm.company.com/v1"
INTERNAL_OPENAI_COMPATIBLE_API_KEY="sk-xxx"
INTERNAL_OPENAI_COMPATIBLE_API_MODEL="llama-3.1-70b"
```

### Scenario: Public Demo (No AI)

```bash
# .env - empty, no access keys
# AI disabled by default in settings
```

### Scenario: Browser-Only AI

```bash
# .env - minimal or empty
# Users choose the Wllama model in settings (WebGPU used automatically when available)
# Models download to user's browser (no server AI)
```

## Debugging Configuration

MiniSearch logs internal events to an in-app log panel (see the Logs section of the menu), backed by `logEntriesPubSub` in `client/modules/logEntries.ts`. There is no separate browser-console debug flag to enable.

**Diagnosing empty search results:** the client distinguishes a search that returned no results (a no-results alert, state stays `completed`) from one that failed outright on an outage (a distinct failed state, with a retry on text searches). An empty response that names unresponsive engines is retried within the same budget as a 500 and counts as the second if it is still empty when the retries are spent, since a rate-limited, suspended or CAPTCHA-challenged engine is reported that way and not with a status code. The actual reason is printed to the server's console (via `server/webSearchService.ts`, always-on `debug` logging), either the SearXNG engines that failed (timeouts, suspensions, rate limits, from SearXNG's `unresponsive_engines` field) or a note that all returned results were discarded during processing (missing title, snippet, or media source). Check the server logs (`docker compose logs`) when troubleshooting failed searches.

Check effective configuration:

```typescript
// In browser console
console.log("Settings:", JSON.parse(localStorage.getItem("settings") || "{}"));
console.log("Server config:", await fetch("/api/config").then((r) => r.json()));
```

## Related Topics

- **AI Integration**: `docs/ai-integration.md` - Detailed inference type configuration
- **Security**: `docs/security.md` - Access control and privacy details
- **Deployment**: `docs/overview.md` - Container architecture and production setup
