# Models

pic talks to Anthropic, OpenAI (Chat Completions and Responses), OpenRouter, Google and any
OpenAI-compatible server, with Pi's thinking levels. One conversation can move between providers.

## Providers

Built in, by the name `--model` takes before the slash: `anthropic`, `openai`, `openrouter`, `google`
(Gemini), `xai`, `groq`, `cerebras`, `deepseek`, `together`, `fireworks`, `huggingface`, `nvidia`,
`moonshotai` and `zai`. Each reads its key from its variable ([environment
variables](../reference/env.md)) or the credential store; OpenAI and OpenRouter can instead be
signed in to with a subscription ([sign-in](sign-in.md)). Other providers go in `models.json`.

## Choosing a model

`--model provider/id` picks the model for one command and saves nothing. In the terminal interface,
Alt+P or `/model` opens the picker, `/model NAME` switches, and Ctrl+P cycles models; whichever you
choose, the next new conversation, `pic ask` and `pic -p` start on it, and the first line says so
(`your last choice`). pic says this once, not at every Ctrl+P step. A model changed by a client of
`pic --mode rpc`, or from a phone through `pic remote`, saves nothing. To keep a fixed default
instead, set `rememberModel` to false and save the default yourself with `pic models --default
NAME`, or with Ctrl+S in the picker (which with `rememberModel` on only says it is already saved).
`pic models` lists the models whose provider has a key, `--all` every one, and `--refresh` fetches
Pi's catalog now; `/scoped-models` (or `pic scoped-models --set PATTERN...`) chooses the models
Ctrl+P cycles.

## A conversation keeps its own

Going on with a conversation (`pic -p -c`, `--session`, `--session-id`, `pic ask --session`,
`pic tui -c`, `/resume`, and `--session` or `switch_session` over RPC) uses the model, key and
thinking level its last request ran with, not the saved default, and says so: `model
openrouter/deepseek/deepseek-v4.1-flash (this conversation's own; --model to change)`, naming the
key when it is not the provider's active one. A fork goes on with the conversation it came from.
`--model` and `--key` still win for one run, and that run becomes the conversation's own.

When its model or key cannot be had now (the provider has no key, the named key was removed, or pic
no longer knows the model), pic never moves it to another model in silence. `-p` and `ask` stop
with one line that names it and the way on, and send nothing:

```
pic: this conversation ran on openai/o4-mini, and openai has no key now; pic auth login adds
one, or --model NAME goes on with another
```

The terminal interface says the same in one line, with the model the next message goes to and
`/model` to pick another; RPC says it on stderr and keeps its model until `set_model`. `pic sessions
--json` gives each conversation's own as `model`, `credential` (`provider:label`) and `thinking`.

## With no saved default

With no saved default (or one whose provider has no key), pic starts on a provider's own default
model, going down Pi's list of providers: the first whose key worked last time, else the first whose
key has not failed, else any with a key. A key that was refused, is out of credit or is rate-limited
is passed over. The terminal interface says which model and why on its first screen, `ask` and `-p`
on stderr: `model openrouter/deepseek/deepseek-v4.1-flash (OPENROUTER_API_KEY is set; anthropic's
key was refused)`. A saved default or last choice is always kept; when its key failed last time the line says so.

The picker shows each model's price per million tokens, input/output, and marks a provider with no
key, a refused key, no credit left, a rate limit or a ChatGPT plan. Models with no key appear once
you type, after the ones you can use; exact and prefix matches come first. Choosing one with no key
opens its login when you send. If the new model does not offer the
thinking level you had, the line names the level it uses instead. `pic models --json` carries the
same mark as `key`.

## Saved endpoints

An OpenAI-compatible server you run or reach, such as a local proxy, can be saved by its address
instead of written into `models.json`: `pic endpoints add proxy http://127.0.0.1:8317/v1`, or "Add
an endpoint" in `/model`. pic fetches the server's model list (`URL/models`) then, and again only
when you ask, with `pic endpoints refresh [NAME]` or "Refresh endpoint models" in the picker. Its
models join the picker, `pic models` and RPC as `NAME/MODEL`, marked "from NAME", and requests to
them go to the server's chat completions. A key, if the server needs one, is typed with `--key`
(echo off, or a line of stdin) and sealed in the credential store under the endpoint's name.

An endpoint never replaces a provider: its name cannot be one pic already has, and adding one
changes no other model, key or your default. Choosing one of its models is like choosing any
other: with `rememberModel` on, new conversations start on it. A failed refresh keeps the list
it had and `pic endpoints list` says why. pic lists what the server says it has and does not
check that each model answers; one it cannot serve fails when you send to it. `pic endpoints
remove NAME` forgets the endpoint and its key.

## Thinking

`--thinking LEVEL` takes off, minimal, low, medium, high, xhigh or max, as the model supports them.
Without it pic uses the level saved for the model (`thinkingLevel:MODEL`), then
`defaultThinkingLevel`, else medium. `pic models --thinking-default LEVEL` saves the default;
Shift+Tab cycles levels in the terminal interface.

## The catalog and models.json

The model list is Pi's catalog: a snapshot built into pic, refreshed from pi.dev when it is newer.
`PIC_MODEL_CATALOG=offline` never fetches it. Models and providers of your own go in
`~/.pic/models.json` (Pi's `~/.pi/agent/models.json` is read when pic has none), in Pi's format;
`PIC_MODELS_FILE` names another file. A key written there comes before the provider's variable and
the credential store ([credentials](credentials.md)).

## Prompt caching

The `cacheRetention` setting is short (the default), long (1 hour; OpenAI 24 hours) or none, as
Pi's; `PI_CACHE_RETENTION=long` works too.
