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

> ## Agent Instructions
> Install the Beam CLI, sign in, and connect coding agents to the Beam MCP server with `curl -fsSL https://www.beam.cloud/install | sh`. To also create a VM, run `curl -fsSL https://www.beam.cloud/install | sh -s -- --vm`.
> VMs are persistent Linux machines without GPUs. Defaults: 4 CPUs, 8 GiB of RAM, a 50 GiB disk, Ubuntu 24.04, and a browser desktop. A running VM accrues usage until you stop, pause, or remove it, or until an idle timeout puts it to sleep.
> Stopping a VM keeps its disk and discards RAM and processes. Pausing keeps both, and resuming restores them. To pause after 5 idle minutes and wake on access, run `beam vm update NAME --ttl 300 --idle-action pause --auto-resume`.
> Core VM commands: `beam vm new NAME`, `beam vm ssh NAME`, `beam vm sync NAME ./dir`, `beam vm exec NAME -- CMD`, `beam vm expose NAME PORT --protected`, `beam vm fork NAME NEW_NAME`, `beam vm pause NAME`, `beam vm stop NAME`, `beam vm rm NAME`.
> For GPUs, use a sandbox or a deployed endpoint. Sandboxes are disposable environments that boot in seconds and fork from snapshots.
> Current rates are at https://www.beam.cloud/pricing.

# Keeping Containers Warm

> Control how long your apps stay running before shutting down.

By default, Beam is serverless, which means your applications will shut off automatically when they're not being used.

## Configuring Keep Warm

You can control how long your containers are kept alive by using the `keep_warm_seconds` flag in your deployment trigger.

For example, by adding a `keep_warm_seconds=300` argument to an endpoint, an idle container remains warm for 5 minutes after activity before it can scale down:

```python theme={null}
from beam import endpoint


# Container stays alive for 5 min before shutting down automatically
@endpoint(keep_warm_seconds=300)
def handler():
    return {}
```

> [!WARNING]
>
> When `keep_warm_seconds` is set in your deployment, it will count as billable
> usage.

## Setting Always-On Containers

> [!NOTE]
>
> Any running containers count towards billable usage. Take care to avoid
> setting `min_containers` unless you're comfortable paying for usage 24/7.

You can configure the number of containers running at baseline using the `min_containers` field.

By setting `min_containers=1`, the autoscaler maintains a target of at least one running container while the deployment is active.

> [!WARNING]
>
> After redeploying, stop any older versions you no longer need. Your
> [rollout strategy](https://docs.beam.cloud/v2/hosting/deployments.md) determines whether they stop automatically.

```python theme={null}
from beam import endpoint, QueueDepthAutoscaler


@endpoint(
    autoscaler=QueueDepthAutoscaler(
        min_containers=1, max_containers=3, tasks_per_container=1
    ),
)
def handler():
    return {"success": "true"}
```

## Pre-Warming Your Container

You can pre-warm your containers by adding `/warmup` to the end of your deployment URL:

```sh theme={null}
curl -X POST 'https://hello-world-a4bdc39-v1.app.beam.cloud/warmup' \
     -H 'Authorization: Bearer [YOUR_TOKEN]'
```

When invoked, this endpoint will send a request to the container to warm-up.

Endpoint, ASGI, and task-queue deployments support the warmup route. This is not a universal route for arbitrary Pod web servers. The gateway also exposes these path forms:

```
id/:stubId/warmup
/:deploymentName/warmup
/:deploymentName/latest/warmup
/:deploymentName/v:version/warmup
```

## Default Container Spin-down Times

After handling a request, Beam keeps containers running ("warm") for a certain amount of time in order to quickly handle future requests. By default, these are the container "keep warm" times for each deployment type:

| Deployment Type | Container Keep Warm Duration |
| - | - |
| Endpoints/ASGI/Realtime | 180s |
| Task Queues | 10s |
| Pods | 600s |


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