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

# Deploying Tensorflow Models

## Saving Models to a Beam Volume

You can mount a `Volume` in your app and save your TF models inside of it.

```python theme={null}
from beam import App, Runtime, Image, Volume

import tensorflow as tf
import tensorflow_hub as hub


beam_cache_path = "./models"

app = App(
    name="tf-example",
    runtime=Runtime(
        cpu=1,
        memory="4Gi",
        image=Image(
            python_version="python3.8",
            python_packages=["tensorflow_hub", "tensorflow"],
        ),
    ),
    volumes=[Volume(path=beam_cache_path, name="models")],
)


@app.rest_api()
def save_model():
    model = hub.load("https://tfhub.dev/google/universal-sentence-encoder/4")
    # Save models to Beam Volume
    tf.saved_model.save(model, beam_cache_path)
```

## Loading Models from a Beam Volume

You can easily read a file saved in the volume by passing in the path to the volume using the `hub.load()` method:

```python theme={null}
@app.rest_api()
def load_saved_model():
    # Load the model from the Beam Volume
    loaded_model = hub.load(beam_cache_path)
    # Run the saved model
    embeddings = loaded_model(["This is an example sentence."])
    # Print model output
    print(embeddings)
```

## Deploying Tensorflow Models

You can deploy your code as a REST API, Task Queue, or Scheduled Job using the `beam deploy` command:

```sh theme={null}
beam deploy app.py:your-function-name
```

When you run this command, your browser window will open the Beam Dashboard. You can copy the cURL or Python request to call the API:

![](https://mintcdn.com/slai-beam/cYxAFgZcnH6nQdWb/img/examples/slack/call-api.png?fit=max\&auto=format\&n=cYxAFgZcnH6nQdWb\&q=85\&s=3731322b6a72248862a8fa50e064dab2)

After making a request, you'll see metrics appear in the dashboard:

![](https://mintcdn.com/slai-beam/cYxAFgZcnH6nQdWb/img/examples/slack/metrics.png?fit=max\&auto=format\&n=cYxAFgZcnH6nQdWb\&q=85\&s=2a5c1f458a87eec07f6126c0a03afd77)


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