Models and context
ZettCode talks to any OpenAI-compatible endpoint: a hosted API, a gateway in front of several providers, or a model running on your own machine. An entry can ask for Anthropic's Messages API instead with anthropic = true. What it needs to know is in Configuration.
Switching
/model opens a picker over the conversation. Enter selects for later requests — the one already running is not disturbed — and the header shows the new name immediately. /model DeepSeek Pro also works, matching either the display name or the model id, for when you know exactly what you want.
Every row starts with where the model came from: file, or plugin <host> for one a plugin offers. The suggestion menu after /model carries the same source and the protocol beside each name. The zettcode[models] extra adds one official model for each vendor key in the environment; see Plugins. They are not in the configuration file: the plugin describes the host, and the runtime reads the token from the environment variable the plugin names, once, when it is built. A row that says needs $ACME_API_KEY is one whose variable was not set at that moment: export it and start the session again. /config lists the file's models only.
Each model keeps its own token, endpoint, and window, so switching between a local server and a hosted one is one keystroke rather than an edit and a restart.
For example, configure DeepSeek Pro and DeepSeek Flash with the two-model example, then try:
/model DeepSeek Pro
Explain the trade-offs in this module before making changes.
/model DeepSeek Flash
Read this screenshot and describe the error message.The screenshot request needs an attached image and a model configured with multimodal = true. Choosing a model does not attach an image for you. The conversation remains the same when you switch; use /new for a clean start.
Reasoning effort
/effort picks how much the model should think before answering:
| Level | What it is for |
|---|---|
off | Request no deliberate reasoning, subject to the endpoint's support. |
minimal | A token of thought, fastest. |
low | Quick answers for small edits. |
medium | The default balance. |
high | More thought on hard problems. |
xhigh | A long think on hard problems. |
max | The highest budget the provider accepts. |
ultra | Highest requested level; availability depends on the endpoint. |
← and → slide the knob one level and the name over it follows; nothing changes until Enter, which applies the level to later requests, and Esc leaves the level as it was. The choice is recorded with the session: resuming that session puts the level back. It is not a setting in config.toml — a new session starts at the configured reasoning_effort. For example:
/effort low
Explain what this regular expression matches.
/effort high
Review this locking code for deadlocks and races; do not edit it yet.The endpoint decides the actual reasoning budget. Not all endpoints support all levels, and a gateway may reject an unsupported value rather than map it. DeepSeek documents its current mapping in Thinking Mode. In this client, Chat Completions with /effort off omits reasoning_effort; it does not send DeepSeek's separate thinking toggle, so it is not a guarantee that a provider with thinking enabled by default will disable it.
What a session restores
A session records the model and reasoning level it last used. Resuming it — /resume, /fork or zettcode -r — switches back to both, and the conversation says so.
- Switching with
/modelalone records nothing; a turn on it does. A/btwside question records nothing. - A session with no record keeps the model selected when you open it.
- If the recorded model is no longer configured, or two entries share its name, ZettCode stays on the current model and says so.
- A level the current model does not take moves to the nearest one it does; the session's own record is unchanged.
- A daemon's
--effortapplies to that process, not to the session.
The context window
Every model has a limit on how much it can read at once, and ZettCode keeps a request inside it: ctx 34.0% in the status line is how full it is, /context is the whole picture, and the request is compacted before it can overflow, at compact_percent of the window. Setting the window and the trigger is in Configuration.
What each number on /context means, where the tokens go, what compaction costs and how to keep a request small are in The context window. Two things worth knowing here:
- The status line's
ctxis the request as a share of the window; a/contextrow is a source as a share of the request. They are different denominators and a row can be 60% of one and 30% of the other. compact_percentis a fraction of the window, not of what is left: at 80%, a 200,000-token window is compacted from 160,000.
Reading the status line
↑18.4k ↓900 · 71.2% cached · 74 tok/s · ctx 12.3% — in order: tokens sent, tokens generated, the share of the input the provider served from its cache, generated tokens per second, and how full the window was on the newest request. Input/output totals accumulate across the session; context occupancy is a snapshot, not an accumulated percentage.
| Field | How to read it |
|---|---|
↑ / ↓ | Cumulative input and output tokens reported by the provider. Repeated context counts as input each time it is sent. |
cached | Cumulative cache-hit input tokens ÷ cumulative input tokens. 60,000 hits out of 100,000 input tokens is 60.0%. Left out when the provider reported no cache read, which is not the same as a miss. |
tok/s | The provider's output tokens divided by the time from the first token of the reply to its end; not the wait for the first token, nor the time spent on tools, approvals, or reading the answer. The tokens that arrived with the first token are counted, so the figure reads a little high. |
ctx | Latest context occupancy relative to the selected model's configured window. When a provider reports no input tokens, the last figure it did report plus everything appended since is measured instead. |
An endpoint that does not report cache-hit usage cannot provide a meaningful hit-rate measurement here. These statistics are not a bill; check the provider's dashboard for charged usage.
The cache figure is worth understanding, because it is where time and money go. Providers cache a prefix of the request: if the beginning of a request is byte-for-byte identical to the previous one, that part is billed and served more cheaply. That is why the system prompt carries the date and not the time, project instructions are read in a fixed order, and /context is safe to open between turns — a stable prefix helps reuse cached input. There is no universal "good" percentage: model switches, compaction, changing tool definitions, and the provider's cache lifetime can all lower it. Newly generated output can only become cached input when a later request sends it back.