> ## 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.

# Deactivate a run

> Save the checkpoints you need, then deactivate a Loops run to end it and its paired sampler in either availability mode.

Deactivation ends a Loops run and its paired sampler. Save the checkpoints you need first: an ended run can't resume, but saved checkpoints remain available to [download or deploy](https://docs.baseten.co/loops/deploy-checkpoints.md), or to start a new run from.

Closing your Python client releases local connections and stops its keepalive. It doesn't deactivate the run.

## When to deactivate

* **Serverless:** An idle run incurs no token charges, so deactivation isn't required to avoid idle billing. Deactivate the run when you want to end it and its paired sampler.
* **Dedicated:** Deactivate the run when you finish to shut down its trainer and paired sampler deployments and stop GPU billing. Otherwise, the run [ends after a period of inactivity](#when-a-run-ends-on-its-own).

## Deactivate and check the run

Use the run ID from `TrainingClient.run_id` or [list your runs](https://docs.baseten.co/reference/cli/baseten/loops.md#list). Set `BASETEN_API_KEY` to your [workspace API key](https://docs.baseten.co/organization/api-keys.md).

> [tab] Baseten CLI
>
> **To deactivate the run**:
>
> Run the following command, replacing `<run_id>` with your run ID:
>
> ```bash theme={"system"}
> baseten loops run deactivate --run-id "<run_id>"
> ```
>
> Confirm when prompted. Pass `--yes` to skip the prompt in scripts.
>
> Then check the run's status:
>
> ```bash theme={"system"}
> baseten loops run describe --run-id "<run_id>" --output json
> ```
>
> Check that the described run has `status.name` set to `INACTIVE`.

> [tab] REST API
>
> **To deactivate the run**:
>
> Send the following requests, replacing `<run_id>` with your run ID:
>
> ```bash theme={"system"}
> curl --request POST \
>   --url "https://api.baseten.co/v1/loops/runs/<run_id>/deactivate" \
>   --header "Authorization: Bearer $BASETEN_API_KEY"
>
> curl --request GET \
>   --url "https://api.baseten.co/v1/loops/runs/<run_id>" \
>   --header "Authorization: Bearer $BASETEN_API_KEY"
> ```
>
> The deactivation request returns HTTP 200. Check that the follow-up response has `run.status.name` set to `INACTIVE`.

> [tab] Loops cookbook
>
> **To deactivate the run**:
>
> From your cookbook project, run the following command with your run ID or the path to its run directory:
>
> ```bash theme={"system"}
> uv run loops deactivate "<run_id>"
> ```
>
> The command prints the deactivated run ID. To check its status, send the following request with the same run ID:
>
> ```bash theme={"system"}
> curl --request GET \
>   --url "https://api.baseten.co/v1/loops/runs/<run_id>" \
>   --header "Authorization: Bearer $BASETEN_API_KEY"
> ```
>
> Check that the response has `run.status.name` set to `INACTIVE`.

## Other resources

Standalone samplers have their own lifecycle. Use [Deactivate a sampler](https://docs.baseten.co/reference/loops-api/samplers/deactivate-a-sampler.md) when you finish with one. Deactivating a run doesn't stop an inference deployment created from its checkpoint or release external sandboxes. Follow the example's cleanup instructions for those resources.

## When a run ends on its own

A dedicated run stays active, and bills for GPU time, while a training client keeps it alive, even between training calls. Once the client disconnects, the run ends after 15 minutes with no requests by default. Explicit deactivation ends it without waiting for that inactivity period.

To change the inactivity period, [configure the timeout when you create a dedicated run](https://docs.baseten.co/loops/availability-modes/dedicated.md#configure-the-inactivity-timeout). Saved checkpoints remain available after the run ends.
