# Models

> The language model the agent thinks with, one per role if you like, a fallback, and the models for memory search and pictures.

Source: https://nestorhome.dev/docs/models/

Any language model, hosted or local, that supports tool calls.

*Models in the settings: each profile, its type and the roles it serves*

## Choose a provider

`nestor init` writes one profile, `models.main`. To change provider, replace it with a block below,
then `nestor check`. The key goes in `.env` as `MODEL_API_KEY`; local servers need none.

### OpenRouter

The default, and the tested provider.

```ini
MODEL_API_KEY=sk-or-...
```

```yaml
models:
  main:
    type: language
    provider: openai-compatible
    base_url: https://openrouter.ai/api/v1
    api_key: ${MODEL_API_KEY}
    model: anthropic/claude-haiku-5.5
```

### OpenAI

```ini
MODEL_API_KEY=sk-...
```

```yaml
models:
  main:
    type: language
    provider: openai-compatible
    base_url: https://api.openai.com/v1
    api_key: ${MODEL_API_KEY}
    model: gpt-5-mini
```

### Mistral

```ini
MODEL_API_KEY=...
```

```yaml
models:
  main:
    type: language
    provider: openai-compatible
    base_url: https://api.mistral.ai/v1
    api_key: ${MODEL_API_KEY}
    model: mistral-small-latest
```

### Groq

```ini
MODEL_API_KEY=gsk_...
```

```yaml
models:
  main:
    type: language
    provider: openai-compatible
    base_url: https://api.groq.com/openai/v1
    api_key: ${MODEL_API_KEY}
    model: openai/gpt-oss-120b
```

### Gemini

Native: PDFs read whole, prompt cached by Gemini.

```ini
MODEL_API_KEY=...
```

```yaml
models:
  main:
    type: language
    provider: gemini
    api_key: ${MODEL_API_KEY}
    model: gemini-flash-latest
```

`extra_body` carries `generationConfig` (`thinkingConfig`, `maxOutputTokens`).

### Anthropic

Native: prompt and conversation cached, PDFs read whole.

```ini
MODEL_API_KEY=sk-ant-...
```

```yaml
models:
  main:
    type: language
    provider: anthropic
    api_key: ${MODEL_API_KEY}
    model: claude-haiku-5-5
```

`effort` (`low` to `max`) sets how much Claude thinks; `max_tokens` caps the answer, thinking
included (64000).

### Ollama

`model` is one the server has pulled.

```yaml
models:
  main:
    type: language
    provider: openai-compatible
    base_url: http://localhost:11434/v1
    model: qwen3
```

### LM Studio

`model` is the loaded model's identifier.

```yaml
models:
  main:
    type: language
    provider: openai-compatible
    base_url: http://localhost:1234/v1
    model: qwen3-8b
```

### vLLM

Set a key only if vLLM runs with `--api-key`.

```yaml
models:
  main:
    type: language
    provider: openai-compatible
    base_url: http://localhost:8000/v1
    model: Qwen/Qwen3-8B
```

### llama.cpp

`llama-server` serves the model it loaded, whatever `model` says.

```yaml
models:
  main:
    type: language
    provider: openai-compatible
    base_url: http://localhost:8080/v1
    model: local
```

A local model is slower, and the voice feels it first. From Docker, use
`http://host.docker.internal:<port>/v1`; on Linux, make the server listen on all interfaces
(`OLLAMA_HOST=0.0.0.0`, `--host 0.0.0.0` for llama.cpp).

## Types

Each model has a `type` (`language`, `embedding`, `transcription`, `speech`, `speaker`, `image`)
and a `provider`. See [Voice](https://nestorhome.dev/docs/voice/) and [Speakers](https://nestorhome.dev/docs/agent/speakers/).

## Roles

| Role                   | What it does                                       | When unset                   |
| ---------------------- | -------------------------------------------------- | ---------------------------- |
| `agent.spoken`         | answers aloud: the first words must come fast      | `agent.written`              |
| `agent.written`        | answers in writing                                 | `agent.spoken`               |
| `agent.titles`         | titles each chat of the admin; a small model does  | `agent.written`              |
| `watches.model`        | sorts incoming mail for the watches                | `agent.written`              |
| `memory.consolidation` | summarizes each conversation once it is over       | `agent.written`              |
| `agent.transcription`  | hears voice messages                               | the only transcription model |
| `agent.speech`         | answers a voice message with one                   | the only speech model        |
| `agent.images`         | draws pictures                                     | the only image model         |

A fast model for the voice, a stronger one in writing:

```yaml
models:
  quick:
    type: language
    provider: openai-compatible
    base_url: https://openrouter.ai/api/v1
    api_key: ${MODEL_API_KEY}
    model: anthropic/claude-haiku-5.5
  deep:
    type: language
    provider: openai-compatible
    base_url: https://openrouter.ai/api/v1
    api_key: ${MODEL_API_KEY}
    model: anthropic/claude-sonnet-5.5

agent:
  spoken: quick
  written: deep
```

## Settings

| Key              | Models                              | What it does                                                         |
| ---------------- | ----------------------------------- | -------------------------------------------------------------------- |
| `extra_body`     | all language models                 | merged into every request (routing, reasoning, `generationConfig`)    |
| `read_timeout_s` | all language models                 | in seconds: 30 for `openai-compatible`, 60 for `anthropic` and `gemini` |
| `fallback`       | all language models                 | the model that answers when this one fails ([Fallback](#fallback))   |
| `vision`         | `openai-compatible`                 | `true` for a model that reads images: it then sees the photos sent   |
| `cache_control`  | `openai-compatible`                 | the provider’s prompt cache, on by default for OpenRouter and Anthropic |

`anthropic` and `gemini` see images and read PDFs by themselves.

## Fallback

When a model fails before answering, its `fallback` answers, in every role, and the journal says
so. A fallback may have its own, and gets no pictures or documents it cannot take.

```yaml
models:
  claude:
    type: language
    provider: anthropic
    api_key: ${ANTHROPIC_API_KEY}
    model: claude-sonnet-5-5
    fallback: gemini
  gemini:
    type: language
    provider: gemini
    api_key: ${GEMINI_API_KEY}
    model: gemini-flash-latest
```

A model that fails mid-answer is not replaced.

## Search by meaning

An embedding model finds memories by meaning ("what does Léa eat?" finds "Léa is vegetarian"):

```yaml
models:
  vectors:
    type: embedding
    provider: openai-compatible
    base_url: https://openrouter.ai/api/v1
    api_key: ${MODEL_API_KEY}
    model: openai/text-embedding-3-small
    dimensions: 1536

memory:
  embedder: vectors
```

| Key                                | What it does                                                    |
| ---------------------------------- | --------------------------------------------------------------- |
| `dimensions`                       | the vector size                                                 |
| `send_dimensions`                  | `true` asks a model that can shorten its vectors for that size  |
| `query_prefix`, `document_prefix`  | for a model that expects a prefix (`query: `)                   |

Any OpenAI-compatible `/embeddings` endpoint works ([Memory](https://nestorhome.dev/docs/agent/memory/)).

## Pictures

Nestor sends the pictures it draws in the admin's chat and messaging apps. One asked for aloud
stays in the admin's journal.

```yaml
models:
  painter:
    type: image
    provider: openai-compatible
    base_url: https://openrouter.ai/api/v1
    api_key: ${MODEL_API_KEY}
    model: google/gemini-2.5-flash-image
    endpoint: chat
```

`endpoint: images` (default) uses `/images/generations`; `chat` uses Chat Completions, as on
OpenRouter. `size` sets the size when the model takes one (`1024x1024`).
