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

# Availability modes

> Compare the serverless and dedicated availability modes, see how Loops chooses one for each run, and choose one yourself.

Loops trains and samples in two availability modes: serverless and dedicated. Start with serverless in the [Loops quickstart](https://docs.baseten.co/loops/quickstart.md); use dedicated when you need a model or configuration serverless doesn't support.

| | Serverless | Dedicated |
| - | - | - |
| What you manage | Your training code. There are no deployments to size, start, or shut down. | Your training code, plus your run's trainer and sampler deployments: replica counts, capacity type, and reuse. |
| Billing | Tokens you train and sample. | GPU time while the run's trainer and sampler run, including time between training operations. |
| Models | Models the [model catalog](https://docs.baseten.co/loops/supported-models.md) lists as **Serverless and dedicated**, at the sequence lengths listed there. | Every model in the [catalog](https://docs.baseten.co/loops/supported-models.md). |
| Ending a run | [Deactivate the run](https://docs.baseten.co/loops/deactivate-a-run.md) to end it and its paired sampler. An idle run incurs no token charges. | Deactivate the run to stop GPU billing, or it [ends after inactivity](https://docs.baseten.co/loops/deactivate-a-run.md#when-a-run-ends-on-its-own), 15 minutes by default. |

## When to use each mode

Use the dedicated mode when you need a model or configuration serverless doesn't support, or when you need to control a run's throughput with replica counts.

The serverless mode fits experimentation:

* **No capacity to reserve.** Runs use shared capacity, so you don't reserve GPUs before you start.
* **Billed for usage.** You pay for the tokens you train and sample, so time spent reading results or revising a reward function between steps costs nothing.

The dedicated mode fits these cases:

* **Models and configurations serverless doesn't support.** Every model in the [catalog](https://docs.baseten.co/loops/supported-models.md) trains in the dedicated mode, including models, sequence lengths, and LoRA ranks that serverless doesn't support.
* **Scaling out a run, especially asynchronous RL.** Add [trainer replicas](https://docs.baseten.co/loops/availability-modes/dedicated.md#scale-the-trainer) for update throughput and sampler replicas for rollout throughput, and use [spot capacity](https://docs.baseten.co/loops/availability-modes/dedicated.md#spot-capacity) for interruptible runs that resume from checkpoints.
* **Planned, sustained runs.** In the dedicated mode, a run's deployments belong to it for its whole duration. To plan for a large run, [request more access](https://docs.baseten.co/loops/overview.md#request-more-access).

## How Loops chooses a mode

By default, a run uses the serverless mode when serverless supports the model and the run's LoRA rank and sequence length. Otherwise, the run uses the dedicated mode. A run that reuses another run's deployments stays in the dedicated mode. A run's paired sampler uses the same mode as the run.

## Choose a mode

Set `scope` to `serverless` when you create a run or a standalone sampler. If serverless can't accept the run, the request fails instead of falling back to dedicated GPU billing.

**scope** `string` (default: default)

Where the run or standalone sampler trains and samples.

* `default`: Loops chooses, as described above.
* `serverless`: the serverless mode. Creating the run fails, instead of falling back to the dedicated mode, if serverless doesn't support the model or the requested configuration, or can't start the run.
* `deployment`: the dedicated mode, with trainer and paired sampler deployments for the run, billed for GPU time. Use it to scale out a model that's also available in the serverless mode.

> [tab] Python SDK
>
> **To use the serverless mode**:
>
> Pass `scope` when you create the training client:
>
> ```python theme={"system"}
> from baseten.loops import ServiceClient
>
> training_client = ServiceClient().create_lora_training_client(
>     base_model="zai-org/GLM-5.3-Flash",
>     scope="serverless",
> )
> ```
>
> [`ServiceClient.create_sampling_client()`](https://docs.baseten.co/reference/sdk/loops/service-client) takes the same `scope` argument for a standalone sampler.

> [tab] Environment variable
>
> **To use the serverless mode**:
>
> Set `BASETEN_LOOPS_SCOPE` for the process. It applies to every run and standalone sampler the process creates without an explicit `scope` argument:
>
> ```bash theme={"system"}
> BASETEN_LOOPS_SCOPE=serverless uv run python train_loops.py
> ```

> [tab] REST API
>
> **To use the serverless mode**:
>
> Add `scope` to the body of [`POST /v1/loops/trainers`](https://docs.baseten.co/reference/loops-api/runs/create-a-trainer):
>
> ```bash theme={"system"}
> curl -s https://api.baseten.co/v1/loops/trainers \
>   -H "Authorization: Bearer $BASETEN_API_KEY" \
>   -H "Content-Type: application/json" \
>   -d '{
>     "session_id": "<session_id>",
>     "base_model": "zai-org/GLM-5.3-Flash",
>     "scope": "serverless"
>   }'
> ```

Replica counts and the capacity type set by `availability_model` configure deployments; they don't select the mode. Set `scope` to `deployment` to make sure they apply. For more information, see [Dedicated Loops](https://docs.baseten.co/loops/availability-modes/dedicated.md).

To check which models and sequence lengths your workspace can use, see [Supported models](https://docs.baseten.co/loops/supported-models.md).
