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

# Models

> Five adapters, any model, one interface — and the adapters are the only packages that know a vendor.

The turn loop asks a `ModelAdapter` for one decision at a time and receives a stream of
`ModelEvent`s: text deltas, tool calls, usage. Everything above the adapter is vendor-blind,
and swapping one changes no line of the harness.

## The adapters

| Package                            | Covers                                                                                                                                                   | Key                                                                                       |
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
| `@nativeharness/adapter-anthropic` | Claude — per-model facts for 11 models, adaptive thinking, effort levels                                                                                 | `ANTHROPIC_API_KEY`                                                                       |
| `@nativeharness/adapter-openai`    | OpenAI, xAI, DeepSeek, Moonshot, MiniMax, Zhipu — services whose API *is* chat-completions — plus Groq and Mistral through their compatibility endpoints | `OPENAI_API_KEY`, `XAI_API_KEY`, `DEEPSEEK_API_KEY`, `GROQ_API_KEY`, `MISTRAL_API_KEY`, … |
| `@nativeharness/adapter-google`    | Gemini — `thought` parts, reasoning tokens split from output                                                                                             | `GEMINI_API_KEY` or `GOOGLE_API_KEY`                                                      |
| `@nativeharness/adapter-cohere`    | Cohere v2 — the tool plan, streamed before tool calls                                                                                                    | `COHERE_API_KEY` or `CO_API_KEY`                                                          |
| `@nativeharness/adapter-ollama`    | local models — asks the model its real context window and whether it can use tools at all                                                                | none                                                                                      |

```ts theme={null}
new AnthropicAdapter({ model: "claude-opus-5", effort: "high" });
new OpenAIAdapter({ provider: "groq", model: "…" });
new OllamaAdapter({ model: "qwen3" });
```

Each adapter reports its model's real context window, which is what compaction budgets
against — not a guessed number.

## Scripted, for tests

`ScriptedAdapter` from `@nativeharness/agent` plays a fixed sequence of decisions: text, tool
calls, or a thrown error to exercise the failure path. It is how the harness's own suite runs
a whole turn — a real command, in a real sandbox — with no key, and how the CLI's
`--model scripted:<file>` works.

It also declares itself **deterministic**, which is the one case the agent will run on a
non-isolating sandbox provider: no model is deciding anything, so there is nothing to contain.

## Choosing from the CLI

`nhar chat` takes `--model`, then `$NH_MODEL`, then the first key it finds in the environment,
in this order: Anthropic, OpenAI, Google, Cohere, xAI, DeepSeek, Groq, Mistral. Adapters are
loaded only when chosen, so an Anthropic user never loads the OpenAI SDK.

```bash theme={null}
nhar chat <id> --model anthropic/claude-opus-5
nhar chat <id> --model ollama/qwen3
nhar chat <id> --model scripted:./turn.json
```

## Writing one

A `ModelAdapter` is one method, `decide`, taking the system prompt, the messages, the tools and
a token budget, and yielding `ModelEvent`s — plus an `info` block naming the model, its
context window and its capabilities. The interface is
[`model-adapter.ts`](https://github.com/davmixcool/nativeharness/blob/main/packages/types/src/model-adapter.ts);
the Ollama adapter is the smallest real one to read.
