Skip to content
15 changes: 14 additions & 1 deletion docs/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ Core AI settings that apply to all providers.

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| `provider` | string | -- | LLM provider: `gemini`, `claude`, `claude-cli`, `codex-cli`, `copilot-cli`, `devin-cli`, `kiro-cli`, `goose` (alias `goose-cli`), `openai`, `openai-compatible`, `ollama`, `vllm`, `bedrock`, `vertex`. `bedrock` and `vertex` need a build with `--features bedrock` / `--features vertex`; without it their `[ai.bedrock]` / `[ai.vertex]` table is rejected as an unknown field. |
| `provider` | string | -- | LLM provider: `gemini`, `claude`, `claude-cli`, `codex-cli`, `copilot-cli`, `devin-cli`, `kiro-cli`, `goose` (alias `goose-cli`), `openai`, `openai-compatible`, `mistral`, `ollama`, `vllm`, `bedrock`, `vertex`. `bedrock` and `vertex` need a build with `--features bedrock` / `--features vertex`; without it their `[ai.bedrock]` / `[ai.vertex]` table is rejected as an unknown field. |
| `model` | string | -- | Model identifier (provider-specific). |
| `max_input_tokens` | integer | `150000` | Maximum input tokens per request. |
| `max_interactions` | integer | `100` | Maximum tool-call rounds per review turn. |
Expand Down Expand Up @@ -215,6 +215,19 @@ Settings for the OpenAI providers (`provider = "openai"` or `provider = "openai-
| `extra_body` | table | empty | Top-level JSON fields added to every request body. Fields Sashiko sets itself (`model`, `messages`, `tools`, `temperature`, `max_tokens`, `max_completion_tokens`, `response_format`, `reasoning_effort`) are rejected at startup; set reasoning effort with `effort` instead. |
| `api` | string | `"chat"` | Which OpenAI endpoint to speak: `"chat"` for `/v1/chat/completions`, or `"responses"` for `/v1/responses`. Only OpenAI's own API serves the latter, and it is the only endpoint that accepts function tools and a reasoning effort in the same request. |

#### `[ai.mistral]`

Settings for the Mistral AI provider (`provider = "mistral"`). The API key
comes from `MISTRAL_API_KEY` (or `LLM_API_KEY`).

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| `base_url` | string | `https://api.mistral.ai/v1/chat/completions` | Chat completions endpoint: the API host, any `…/v1` root (the `/chat/completions` suffix is appended), or the full URL. Any other path is rejected at startup. |
| `max_tokens` | integer | `32768` | Max output tokens per response, reasoning tokens included. The prompt plus `max_tokens` may not exceed the model's context length. |
| `context_window_size` | integer | model-derived | Context window override; `1048576` for the hosted `zai-glm-*`/`glm-*` models, `131072` for everything else. |
| `effort` | string | -- | Reasoning effort sent as the `reasoning_effort` request field when a review stage does not ask for one itself: `"none"`, `"minimal"`, `"low"`, `"medium"`, `"high"`, `"xhigh"`, or `"max"`. Leave unset for the model default. |
| `prompt_caching` | bool | `true` | Route requests that share a prompt prefix — every tool round of a session, and every session of a review stage — to Mistral's prompt cache with a stable `prompt_cache_key`, so the repeated prefix bills at 10% of the input price instead of full price on every round. Disable for gateways that reject the field. |

#### `[ai.ollama]`

Settings for the Ollama provider (`provider = "ollama"`).
Expand Down
32 changes: 32 additions & 0 deletions docs/examples/Settings.mistral.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Mistral AI (https://api.mistral.ai) and Mistral-shaped gateways.
# Export MISTRAL_API_KEY (or LLM_API_KEY).
# Setup: docs/llm-providers.md, section "Mistral AI".

[ai]
provider = "mistral"
model = "zai-glm-5-3-flash"
# The hosted zai-glm models take a 1M-token context; leave room below it
# for the reply.
max_input_tokens = 400000

[ai.mistral]
# Chat completions endpoint: the API host, any .../v1 root (the
# /chat/completions suffix is appended), or the full URL.
# base_url = "https://api.mistral.ai"
# Completion token cap, thinking included. The prompt plus max_tokens may
# not exceed the model's context length.
# max_tokens = 32768
# Reasoning effort sent when a review stage does not ask for one itself:
# "none", "minimal", "low", "medium", "high", "xhigh", or "max".
# effort = "medium"
# Context window override; defaults to 1M for the zai-glm-*/glm-* models
# and 131072 for everything else.
# context_window_size = 1048576
# Route requests sharing a prompt prefix (every tool round of a session,
# and every session of a review stage) to Mistral's prompt cache with a
# stable prompt_cache_key: cached prefix tokens bill at 10% of the input
# price. Turn this off only for gateways that reject the field.
# prompt_caching = true

[review]
concurrency = 4
58 changes: 58 additions & 0 deletions docs/llm-providers.md
Original file line number Diff line number Diff line change
Expand Up @@ -669,3 +669,61 @@ Everything else in `[ai.openai_compat]` applies to both, except
`extra_headers`, and `extra_body`, which shape a chat completion only.
Setting any of them with `api = "responses"` is refused at startup
rather than ignored.

## Mistral AI

Sashiko has a native Mistral provider (`provider = "mistral"`) for
`https://api.mistral.ai` and Mistral-shaped gateways. The Mistral chat
completions API is close to the OpenAI one but not close enough for the
generic compatible client: replies carry the assistant text as an array of
typed content blocks, where the chain of thought arrives as `thinking`
blocks next to `text` blocks instead of a `reasoning_content` string. The
provider speaks that shape natively, so a reasoning model's thinking is
kept in the conversation across tool calls without extra settings.

**Apply the example config:**

```bash
cp docs/examples/Settings.mistral.toml Settings.toml
```

Export the API key as `MISTRAL_API_KEY` (or `LLM_API_KEY`):

```bash
export MISTRAL_API_KEY=...
```

Third-party models hosted on Mistral, such as the `zai-glm-*` series, work
the same way; their 1M-token context is picked up from the model name, so
`max_input_tokens` in `[ai]` can be raised accordingly.

```toml
[ai]
provider = "mistral"
model = "zai-glm-5-3-flash"
max_input_tokens = 400000

[ai.mistral]
# Sent when a stage does not ask for an effort level itself. The API also
# accepts "none", "minimal", "xhigh" and "max".
# effort = "medium"
# max_tokens = 32768
```

`base_url` accepts the API host (`https://api.mistral.ai`), any `…/v1`
root (the `/chat/completions` suffix is appended, which covers gateways
behind a path prefix), or the full chat completions URL. Any other path is
rejected at startup. Tool calling, JSON mode, and `reasoning_effort` are
supported; an effort level the model rejects comes back as a 400, which
ends the run as a fatal error.

**Prompt caching** is on by default (`[ai.mistral] prompt_caching`).
Mistral's chat completions API routes prompt caching by a client-chosen
`prompt_cache_key`: requests carrying the same key land where their shared
prefix is already cached, and the cached prefix bills at 10% of the input
token price. Sashiko keys a request on its model, system prompt, and tool
definitions — the part of the prompt every tool round of a session
repeats, and every session of a review stage repeats across patchsets —
so a review's growing conversation is billed as one cached prefix instead
of being re-paid in full on every round. The key is a digest, so no
prompt content travels inside it.
Loading