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

# CAS Images

> Build, import, and run Content Addressable Streaming (CAS) images.

Content Addressable Streaming (CAS) is Tensorlake's newer format for sandbox images and snapshots. A sandbox created from a CAS image or snapshot starts running before its contents
have been downloaded from the underlying blob storage. The missing parts stream in the background at high throughput, while the memory and I/O requests the sandbox makes are served
at high priority to keep their latency low. Images and snapshots are deduplicated, so only data that isn't already cached locally is downloaded. The result is fast and consistent
cold starts, with extra disk read latency only for a short time after creation.

Sandboxes created from CAS images and snapshots run on Tensorlake's next-generation dataplane, which enables [live resize](/sandboxes/live-resize) and
[nested virtualization](/sandboxes/nested-virt). [GPU sandboxes](/sandboxes/gpu) run on gVisor and use CAS images and snapshots too.

CAS is opt-in. Pass `--cas` to `tl sbx image create` or `tl sbx image import` to build or import a CAS image. A sandbox booted or restored from a CAS image or snapshot takes its
[snapshots](/sandboxes/snapshots) in CAS format too.

## Example: Launch a Sandbox from a CAS Image

The managed [Tensorlake images](/sandboxes/tensorlake-images) are available in CAS form under the `tensorlake/cas/` prefix:

<Tabs>
  <Tab title="CLI">
    ```bash theme={null}
    tl sbx create --image tensorlake/cas/ubuntu-minimal
    ```
  </Tab>

  <Tab title="Python">
    ```python theme={null}
    from tensorlake.sandbox import Sandbox

    sandbox = Sandbox.create(image="tensorlake/cas/ubuntu-minimal")
    ```
  </Tab>

  <Tab title="TypeScript">
    ```typescript theme={null}
    import { Sandbox } from "@tensorlakeai/tensorlake";

    const sandbox = await Sandbox.create({ image: "tensorlake/cas/ubuntu-minimal" });
    ```
  </Tab>
</Tabs>

## Build a CAS Image

Add `--cas` to `tl sbx image create`. Everything else works as described in [Define, Build and Register an Image](/sandboxes/images#define-build-and-register-an-image).

```dockerfile Dockerfile theme={null}
FROM tensorlake/cas/ubuntu-minimal
RUN apt-get update && apt-get install -y python3
```

```bash theme={null}
tl sbx image create ./Dockerfile --registered-name my-cas-image --cas
```

A CAS build resolves the Dockerfile's `FROM` references against the CAS catalog. A Tensorlake image named without the `tensorlake/cas/` prefix is looked up as `tensorlake/cas/<name>`,
so `FROM tensorlake/ubuntu-minimal` builds on `tensorlake/cas/ubuntu-minimal`, and the build fails if that CAS image doesn't exist. Other references, such as `ubuntu:24.04`
or a [private registry](/sandboxes/images#private-registries) image, are pulled from their registry.

Unlike default builds, CAS builds accept Dockerfile build args:

```bash theme={null}
tl sbx image create ./Dockerfile --registered-name my-cas-image --cas \
  --build-arg PYTHON_VERSION=3.12
```

## Import a CAS Image

Add `--cas` to `tl sbx image import` to [import a registry image](/sandboxes/images#import-an-image-from-a-registry) as is:

```bash theme={null}
tl sbx image import pytorch/pytorch:2.4.1-cuda12.1-cudnn9-runtime \
  --registered-name my-gpu-image --cas --disk_mb 20480
```

`--disk_mb` sets the root disk size of sandboxes created from the image, as for any [build or import](/sandboxes/images#build-resources). You can grow it further for an individual sandbox with `--disk_mb` on `tl sbx create`.

## See Also

<CardGroup cols={3}>
  <Card title="Build and Import Images" icon="layer-group" href="/sandboxes/images">
    The build and import workflow that `--cas` plugs into.
  </Card>

  <Card title="Live Resize" icon="expand" href="/sandboxes/live-resize">
    Change the CPUs, memory, and disk of a running CAS sandbox.
  </Card>

  <Card title="Nested Virtualization" icon="cubes" href="/sandboxes/nested-virt">
    Run QEMU/KVM virtual machines inside a CAS sandbox.
  </Card>
</CardGroup>


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