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

> Shut down a standalone Loops sampler when you finish with it, from the Python SDK or the REST API.

Deactivating a standalone sampler shuts it down and stops its billing. A paired sampler stops with its run, so to end one, [deactivate the run](https://docs.baseten.co/loops/deactivate-a-run.md) instead; deactivating a paired sampler directly returns a `409` error that names its run.

You need the sampler's ID: the [`sampler_id`](https://docs.baseten.co/reference/sdk/loops/sampling-client) property of the sampling client that created it, or the `id` from [List samplers](https://docs.baseten.co/reference/loops-api/samplers/list-samplers.md).

The Python SDK and the `curl` examples authenticate with `BASETEN_API_KEY`. Export your [API key](https://docs.baseten.co/organization/api-keys.md) first:

```sh theme={"system"}
export BASETEN_API_KEY="YOUR_API_KEY"
```

> [tab] Python SDK
>
> **To deactivate a standalone sampler**:
>
> Call [`deactivate()`](https://docs.baseten.co/reference/sdk/loops/sampling-client) on the sampling client that created it:
>
> ```python theme={"system"}
> sampling_client.deactivate()
> ```
>
> To deactivate a sampler from another script, call [`deactivate_sampler()`](https://docs.baseten.co/reference/sdk/loops/service-client) on a [`ServiceClient`](https://docs.baseten.co/reference/sdk/loops/service-client), replacing `<sampler_id>` with the sampler's ID:
>
> ```python theme={"system"}
> from baseten.loops import ServiceClient
>
> ServiceClient().deactivate_sampler("<sampler_id>")
> ```
>
> Both calls succeed if the sampler is already inactive. Closing the sampling client with [`close()`](https://docs.baseten.co/reference/sdk/loops/sampling-client) releases its local connections but doesn't deactivate the sampler.

> [tab] REST API
>
> **To deactivate a standalone sampler**:
>
> Send a request to [Deactivate a standalone sampler](https://docs.baseten.co/reference/loops-api/samplers/deactivate-a-sampler.md), replacing `<sampler_id>` with the sampler's ID:
>
> ```bash theme={"system"}
> curl --request POST \
>   --url "https://api.baseten.co/v1/loops/samplers/<sampler_id>/deactivate" \
>   --header "Authorization: Bearer $BASETEN_API_KEY"
> ```
>
> The request succeeds if the sampler is already inactive.

To confirm the sampler stopped, request it and check that `status.name` is `INACTIVE`:

```bash theme={"system"}
curl --url "https://api.baseten.co/v1/loops/samplers/<sampler_id>" \
  --header "Authorization: Bearer $BASETEN_API_KEY"
```

## Next steps

* [Create a standalone sampler](https://docs.baseten.co/loops/standalone-samplers.md): Start another sampler for a base model or checkpoint.
* [Deactivate a run](https://docs.baseten.co/loops/deactivate-a-run.md): End a run and its paired sampler.
