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

# Choose the model

> A run's calls go through your routing rules, so the rule that matches the run's key or project decides which model does the work.

A run's model calls go through your [routing rules](https://docs.sense-lab.ai/sensei/routing/overview.md), the same as calls from your editor. With no rules, Sensei answers them. When a rule matches the run, the model it names does the work: a model on your own OpenAI, Anthropic or Google key, a split between models, or Sensei.

The rest of the run is the same whichever model answers. That covers the sandbox, the tests before and after, the questions it asks you, the Learnings it starts with and the verdict.

## A rule for each need

Rules run top to bottom, and the first rule that matches a call decides. A rule can match on the API key or the project, among other conditions. Keep a rule, with a key of its own, for each way you want work done. Then start each run with the key whose rule you want.

| Rule | When | Route |
| - | - | - |
| Regulated work | **Project data** is regulated | Sensei |
| Runs on GPT | **API key** is `runs-gpt` | `openai/gpt-5` |
| Try Sensei on runs | **API key** is `runs-trial` | Split: Sensei 20%, `openai/gpt-5` 80%, adapting on results |
| Everything else | | Sensei |

GPT-5 does a run started with the `runs-gpt` key. A run started with `runs-trial` draws its model from the split. A regulated project stays on Sensei whatever key starts the run, because its rule is first.

## Set it up

1. Connect a provider key and enable the models runs may use. See [Provider keys](https://docs.sense-lab.ai/sensei/routing/providers.md).
2. Create a Sensei key for the runs. See [Create a key](https://docs.sense-lab.ai/sensei/access.md#create-a-key).
3. Open **Routing** and click **Add rule**. Under **When**, pick **API key** and the key you created. Under **Route**, pick a model or a split.
4. Start runs with that key.

Only an account admin can add provider keys and change routing rules. Any member can create a key and start runs with it.

> [tab] Terminal
>
> ```bash theme={null}
> SENSEI_API_KEY=amfs_... sensei run "Fix the failing test"
> ```
>
> `sensei login` saves a key for every command that follows.

> [tab] Python
>
> ```python theme={null}
> from sensei import Sensei
>
> sensei = Sensei(api_key="amfs_...")
> r = sensei.run(task="Fix the failing test", repo="acme/checkout")
> ```

> [tab] JavaScript
>
> ```ts theme={null}
> import { Sensei } from "@senselab-ai/sensei";
>
> const sensei = new Sensei({ apiKey: "amfs_..." });
> ```

> [tab] API
>
> ```bash theme={null}
> curl -X POST https://runs.sense-lab.ai/v1/runs \
>   -H "Authorization: Bearer amfs_..." \
>   -H "Content-Type: application/json" \
>   -d '{"repo": "acme/checkout", "task": "Fix the failing test"}'
> ```

> [tab] Chat tool
>
> Put the key in the `Authorization` header of the `sensei-runs` server. Every run your assistant starts then follows that key's rule. See [Hand a task to a run](https://docs.sense-lab.ai/sensei/runs/hand-off.md#hand-a-task-to-a-run).

## Runs started without your key

Some runs start without a key of yours, and are given a key made for that run alone:

* a run started from the dashboard
* a run started by a schedule
* a run started from a chat tool you signed in to, instead of giving it a key

That key is new for each run, so a rule on **API key** does not match it. To route these runs, use a rule on **Project**. Such a rule also covers the sessions of every key on the project.

The **Editor** condition does not tell runs apart. A run's calls count as **something else**.

## Splits, attempts and results

A split draws a model once for each attempt of a run. Every step of an attempt is done by the model it drew. A run with several attempts can try different models.

A rule that adapts on results counts a run's verdict. A verified run is a success for the model that did it, and a run that broke a test that passed before is a failure. A run that is not verified counts for neither.

If your provider key is missing or rejected, the call moves to the rule's fallback and ends on Sensei, so the run carries on. If the provider's rate limit is reached, the run waits and asks again, as it does when Sensei is busy.

## See which model did the work

| Where | What it shows |
| - | - |
| The run's page | **Served by**, in the budget section of the rail. When more than one model answered, it shows the calls each one answered. |
| The Runs API | `usage.models` on the run, such as `{"openai/gpt-5": 18}`. See [The run object](https://docs.sense-lab.ai/sensei/reference/runs-api.md#the-run-object). |
| A chat tool | A finished run's reply names the model when it was not Sensei |
| The rule's **Evidence** tab | The run as a task under **Newest tasks**, with a trace of every model call and the model that answered each. See [Evidence and traces](https://docs.sense-lab.ai/sensei/routing/evidence.md). |

![The Budget card on a run's page, ending with Served by](https://mintcdn.com/senselab/7GJRxwA5n_G2FDq5/images/sensei/run-budget.png?fit=max\&auto=format\&n=7GJRxwA5n_G2FDq5\&q=85\&s=184035658bc3af004aba6ab07b5e5355)

## Cost and data

The provider bills the tokens of calls on your key. Sensei charges for those calls by the request, as on [Provider keys](https://docs.sense-lab.ai/sensei/routing/providers.md#billing), and charges the run's computer time as for any run.

A run's cost figure and its spend limit price every model call at Sensei's token rates, including calls on your key. So a run on your key can reach its spend limit before it has cost you that much. If it stops early, give it a higher limit with `--budget`.

The content of calls on your key is never kept for your model. The version of Sensei trained on your project learns only from the calls Sensei answers. See [Provider keys](https://docs.sense-lab.ai/sensei/routing/providers.md#data).

## A model named on the run

A run takes its model from your rules, not from the request. A `model` other than `Sensei` in the request is refused with `invalid_model`. To use another model, start the run with a key whose rule sends it there.


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