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

# Model Selection

> Pick a named client for one run, or switch per model call

Walks through [`WithLLMSelector`](https://docs.agenticenv.ai/features/model-selection) and the per-run `LLMClient` option. Three stub clients, no provider key.

Source: [`examples/agent_with_model_selection/`](https://github.com/agenticenv/agent-sdk-go/tree/main/examples/agent_with_model_selection)

Set `AGENT_RUNTIME=temporal` or `restate` in `examples/.env` to exercise those runtimes. On Temporal, register the same named clients and the same selector mode on the worker.

## What you will see

| Scenario | What happens |
| - | - |
| This run | `LLMClient: "local"` sends the whole run to the local stub. The selector is not set. |
| Sensitive prompt | The selector sees "ssn" in the request and keeps the local client for the run. |
| Tool rounds | Per-call mode uses the cheap client until a tool result is in the request, then the primary client writes the answer. |

## Run

From `examples/`:

```bash theme={null}
go run ./agent_with_model_selection
```

## Expected output

```
=== Scenario 1: this run uses the local client ===
assistant: answered on the local model
llm calls: local=1

=== Scenario 2: sensitive prompts stay on the local client ===
assistant: handled on the local model
llm calls: local=1

=== Scenario 3: cheap client for tool rounds, primary for the answer ===
assistant: answered on the primary model
llm calls: primary=1 cheap=1
```

`primary` in the counts is the empty name: the client from `WithLLMClient`.

## Related

> [card] [Model Selection](https://docs.agenticenv.ai/features/model-selection.md)
>
> Modes, precedence, and limits

> [card] [Error Control](https://docs.agenticenv.ai/features/error-control.md)
>
> Fallback after a model failure still wins for the rest of the run


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.