Providers & Models
Tuse separates provider credentials (stored in SQLite via the CLI; see providers.md) from model metadata (declared in Lua config) and model selection (scoped per session, with a global default for new sessions in SQLite).
Model naming
Models are always identified as <provider>/<model_id>, split on the first /:
- Provider prefix = substring before the first
/. - API
modelsent to the provider = substring after the first/(so nested IDs such asopenrouter/anthropic/claude-sonnet-4work cleanly). - Configured
models[].namevalues must have non-empty provider and model parts and no whitespace.
Availability and discovery
A model is considered available if and only if its provider prefix exists in the session's loaded provider snapshot (loaded from SQLite at startup and refreshed on /reload, reload(), or config.reload). Availability does not query SQLite live and does not verify that the remote catalog listed the model ID; removing a provider with tuse disconnect takes effect in an existing session only after reload or reopen.
The available model list (shown in /models and returned by JSON-RPC model.list) is the sorted, deduplicated union of:
- Configured
models[].nameentries whose provider is in the session's loaded provider snapshot. - Remote model IDs previously fetched via each loaded provider's model-listing endpoint (
GET <base_url>/models, paginated foranthropic-messagesandgoogle-gemini; see providers.md), prefixed with<provider>/and cached in memory until reload.
Background discovery:
- Opening
/modelsin the TUI or calling JSON-RPCmodel.list(withoutcached: true) returns immediately with the currently known list (configured + already-cached remote models) and starts background fetches in parallel (one thread per loaded provider) without waiting for them. - Each provider that responds updates the session cache and emits a
modelsevent so the picker or JSON-RPC client can refresh live (model.list {"cached": true}). - Reload clears the cached remote model list and discards any stale in-flight fetch responses or errors from before the reload.
- Fetch failures emit
error(<provider>: can't fetch models: <err>) without blocking other providers.
Model metadata (models in Lua config)
Context windows, display names, per-model compaction thresholds, and token pricing are declared in the models list of your Lua config (or plugins):
return {
models = {
{
name = "openai/gpt-5",
display = "GPT-5",
window = 200000,
compact_at = 120000,
prices = { input = 2.0, output = 10.0, cache_read = 0.2, cache_write = 2.5 },
},
},
}
| Field | Required | Default | Meaning |
|---|---|---|---|
name |
yes | — | Full provider/model identifier. |
display |
no | "" |
Friendly label shown in the status bar, turn summary, and /models picker (falls back to name). |
window |
no | 0 |
Context window in tokens (0 means unknown). |
compact_at |
no | unset | Per-model compaction threshold in tokens; overrides settings.compact_at in both directions (a positive value overrides global 0, and 0 disables compaction for this model even if global settings.compact_at is positive). |
prices |
no | unset | Table of finite non-negative USD rates per 1,000,000 tokens: input, output, cache_read, cache_write (each defaults to 0). |
- Precedence: Plugin
modelslists come first, then your config'smodels. When multiple entries share the samename, the last entry wins. - Inspecting metadata: Run
tuse models [-c PATH]from the CLI or/sessioninside the TUI. - On reload: Updated metadata takes effect immediately (display name,
ctx_size,compact_at, and recalculated historical session costs) and the cached remote model list is cleared.
Reasoning effort
Valid effort levels are: "default", "low", "medium", "high", "xhigh", "max".
"default"omits effort/thinking parameters from API requests across all four API types.- Non-default effort levels are mapped per provider API type (providers.md):
openai-chat:low,medium,high,xhigh,maxopenai-responses:low,medium,high,xhigh(maxunsupported)anthropic-messages:low,medium,high,max(xhighunsupported)google-gemini:low,medium,high(xhigh,maxunsupported)
- The full 6-value effort set stays available in
/models(annotating unsupported levels when the provider's API type is known) and inmodel.set; unsupported combinations fail fast before any HTTP request on agent turns andllm(). - Invalid effort strings outside the 6-value set are rejected immediately by
model.setandllm().
Selection, persistence, and scoping
- Global defaults: Stored in SQLite
state(modeldefaults to"",effortdefaults to"default"). New sessions inherit these defaults and append an initialsettingsrecord. - Changing model/effort:
- TUI
/modelsprompts for model, then effort (pre-selecting the session's current values), updates the active session, and persists both as the new global defaults. - JSON-RPC
model.set {model, effort?, persist?}defaultseffortto"default"andpersisttotrue. Passingmodel: ""is accepted and clears the session's active model (and the global default ifpersististrue). - Every successful selection appends a
settingsrecord, updates session metadata, and emitsusage—even whenmodelandeffortdid not change. Only themodel_changehook is gated on an actual change.
- TUI
- Session isolation: Existing and resumed sessions keep their own recorded model and effort (the latest
settingsrecord wins on resume, even ifmodelis""). Changing the global default in another session, running/reload, or resuming an older session never overwrites a session's own selection. - Unavailable or unset current model: The
/modelspicker always includes the session's current model even when its provider is not in the loaded provider snapshot (markedunavailablewhen non-empty) and refuses re-selecting an unavailable model (Model \<name>` is unavailable). Submitting a turn with an unavailable or empty model fails withno `connect` entry named `<provider>` for model `<model>``.