> ## Documentation Index
> Fetch the complete documentation index at: https://docs.xynthis.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Model providers

> Configure LLM providers in config.toml, switch the active model, and manage API keys.

Xynthis talks to any LLM through a provider abstraction. Providers live in `~/.xynthis/config.toml`; the active one is a single line you can change from the CLI, the app, or the file itself.

## The config file

```toml theme={null}
[models]
active = "anthropic"

[providers.anthropic]
kind = "anthropic-messages"
base_url = "https://api.anthropic.com/v1/messages"
default_model = "claude-sonnet-4-5"

[providers.ollama]
kind = "openai-chat"
base_url = "http://localhost:11434/v1"
default_model = "llama3.3"

[providers.claude-code]
kind = "subprocess"
command = "claude"
args = ["--print"]
model_arg = "--model"
```

`[models] active` takes `"<provider>"` (uses that provider's `default_model`) or `"<provider>/<model>"` for an explicit model. An optional `[models] fast` names a cheaper target the agent can use for low-effort follow-up turns; unset, every turn goes to `active`.

Each `[providers.<name>]` table supports:

| Field                          | Applies to   | Meaning                                                                                                              |
| ------------------------------ | ------------ | -------------------------------------------------------------------------------------------------------------------- |
| `kind`                         | all          | How Xynthis calls the provider (see below)                                                                           |
| `base_url`                     | HTTP kinds   | For `openai-chat`, the API root without `/chat/completions`; for `anthropic-messages`, the full `/messages` endpoint |
| `default_model`                | all          | Model id used when the target doesn't name one                                                                       |
| `command`, `args`, `model_arg` | `subprocess` | CLI to spawn, its fixed args, and the flag used to pass a model name                                                 |
| `lite`                         | local models | Plain-chat mode for small models; see [Local models](/guides/local-models)                                           |
| `launch_command`               | local models | Shell command that starts the provider's local server; see [Local models](/guides/local-models)                      |

`kind` is one of:

* `anthropic-messages`: Anthropic's `/v1/messages` API with an API key.
* `openai-chat`: any OpenAI-compatible `/v1/chat/completions` endpoint: OpenAI, Ollama, llama.cpp, Groq, DeepSeek, Gemini, xAI, LM Studio, and self-hosted servers.
* `subprocess`: spawn an installed CLI such as `claude` or `codex` and pipe the message through it. Uses the CLI's own auth. Plain text only: no tool use, so the agent can't act, only answer.
* `claude-oauth`: call Anthropic directly with the OAuth token the Claude Code CLI stores in the macOS Keychain. Billed against your Claude subscription, with full tool use; it is the working alternative to `subprocess` for agent work. The `claude-fable` preset uses the same credential pinned to the Claude Fable model, so it appears as its own choice in the picker.
* `codex-oauth`: the equivalent for a ChatGPT subscription via the `codex` CLI's stored token. This targets a private, undocumented endpoint and may break without notice. The model set is what the ChatGPT account allows; unsupported model names are rejected with a 400. The `codex-5-6` preset pins the Codex 5.6 model id (`gpt-5.6-sol`) over the same credential, as its own picker entry.
* `xynthis-llm`: the on-device Xynthis model server on `127.0.0.1:8080`. See [On-device model](/llm/overview).
* `echo`: a deterministic, network-free fallback used when nothing else is configured.

## Switching models

From the CLI:

```bash theme={null}
xynthis models list --all        # configured + built-in presets
xynthis models set anthropic     # provider's default model
xynthis models set openai/gpt-4o # explicit model
xynthis models test              # probe the active target with a tiny completion
xynthis models status
```

From the app: the model picker in the chat bar lists every configured provider. Picking one writes `config.toml` and restarts the daemon: the chat model is constructed at daemon startup, so the restart is what makes the switch take effect. Local providers that aren't running are shown with a start action and are launched via their `launch_command`.

If you edit `config.toml` by hand, one-shot CLI commands pick the change up on their next run, but a running daemon does not. Restart it (or switch once from the app's picker, which restarts it for you).

For a single invocation, override without touching config: `xynthis --llm ollama/llama3.3 chat "..."`, or set `XYNTHIS_LLM_OVERRIDE`.

## API keys

Three places a key can live, checked in this order:

1. **macOS Keychain.** The app's Settings → Models tab stores keys under the `com.xynthis.app` service, one entry per provider (account `<provider>-api-key`). The CLI reads these too, so a key entered in the app works everywhere. macOS only.
2. **`~/.xynthis/auth.json`.** `xynthis login <provider>` prompts for a key interactively and stores it here. `xynthis models add <provider> --api-key <key>` does the same non-interactively.
3. **Environment variables**, via discovery: `xynthis auth scan` finds `ANTHROPIC_API_KEY`, `OPENAI_API_KEY`, `GROQ_API_KEY`, `XAI_API_KEY`, `DEEPSEEK_API_KEY`, and `GEMINI_API_KEY`/`GOOGLE_API_KEY`, plus Claude/Codex OAuth tokens and running local servers (Ollama, LM Studio), and offers to wire what it finds into your config.

`xynthis doctor` diagnoses config, auth, and binary problems when a provider won't respond.
