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

# Chat with DeepSeek R1

In this example we are going to use [vLLM](https://github.com/vllm-project/vllm) to host an API for `deepseek-ai/DeepSeek-R1-Distill-Qwen-7B` on Beam.

> [!WARNING]
>
> This example is out of date. The `vllm` example it downloads uses
> `beam.integrations.VLLM`, which has been removed from the Beam SDK, so the
> deploy step fails with current SDK versions. We're updating it.

> [!WARNING]
>
> This example requires our multi-GPU feature, which needs to be enabled on your
> Beam account. Please send us a message in our [Slack
> Community](https://join.slack.com/t/beam-cloud/shared_invite/zt-4bf7jalhy-KI0ebGXk4vKpcDofwDjCLA)
> and we'll enable it for you!

<video autoPlay muted loop playsInline src="https://mintcdn.com/slai-beam/vg5aTEbpFmupCYom/img/v2/deepseek.mp4?fit=max&auto=format&n=vg5aTEbpFmupCYom&q=85&s=91166c695a600280079907460aa3a20e" />

> [card] [View the Code](https://github.com/beam-cloud/examples/tree/main/vllm)
>
> See the code for this example on Github.

## Initial Setup

First, clone the vLLM example to your computer.

```sh theme={null}
$ beam example download vllm && cd vllm
```

We'll use our vLLM abstraction to host an OpenAI compatible DeepSeek API on Beam.

From inside the vLLM directory, run the following command to deploy the API:

```sh theme={null}
$ beam deploy models.py:deepseek_r1

=> Building image
=> Using cached image
=> Syncing files
=> Uploading
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 28.7/28.7 kB 0:00:00
=> Files synced
=> Deploying
=> Deployed
=> Invocation details

curl -X POST 'https://deepseek-r1-distill-qwen-7b-54b3408-v4.app.beam.cloud' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/json' \
-d '{}'
```

This code will deploy a DeepSeek R1 API on Beam, and print out the API URL.

## Running the API

We provide an interactive command line interface to run the API. You'll be prompted to enter the API URL from the deployment output above. If you select stream mode, the API will stream the response to the console.

```sh theme={null}
$ python chat.py

Welcome to the CLI Chat Application!

Type 'quit' to exit the conversation.

Enter the app URL: https://deepseek-r1-distill-qwen-7b-54b3407-v4.app.beam.cloud

Stream mode? (y/n): y

Model deepseek-ai/DeepSeek-R1-Distill-Qwen-7B is ready
```

> [!WARNING]
>
> The first time you run the API, the model weights will be downloaded from
> Hugging Face. This may take a few minutes, but will be cached for future runs.

## Interacting with DeepSeek R1

You can now interact with the DeepSeek R1 API. The API will stream the response to the console, and print out the tokens generated and the time taken.

```sh theme={null}
**Question:** What’s the meaning of life?

<think>
</think>

The question of the meaning of life is a deep and complex one, and different people and cultures may have different perspectives and answers. Some common themes across various philosophies and belief systems include:

1. **Philosophical Views**
   - **Existentialism**: The belief that life is inherently meaningless, and individuals must create their own meaning.
   - **Mysticism**: The idea that the meaning of life is found within oneself, through spiritual or divine connection.
   - **Buddhism**: The concept of "suffering" (dukkha) and the goal of achieving liberation from suffering, often seen as the ultimate meaning of life.

2. **Cultural and Religious Views**
   - **Religion**: Many religions—such as Christianity, Islam, and Buddhism—propose a higher power or purpose that gives life meaning.
   - **Science and Empiricism**: A materialistic or scientific view often suggests that life’s meaning is derived from personal fulfillment, relationships, or contributing to the greater good.

3. **Personal Perspectives**
   - **Purpose**: Many people find meaning in life by aligning their actions with their personal values, goals, and aspirations.
   - **Relationships**: Building meaningful connections with others can provide a sense of purpose and fulfillment.
   - **Creativity**: Engaging in creative activities, such as art, music, or writing, can bring meaning to life.

Ultimately, the meaning of life is often left open to interpretation, as it can vary greatly depending on individual experiences, beliefs, and contexts. Some find meaning through achieving their personal goals, while others find it in helping others or contributing to the world in some way.

Tokens Generated: 350
Time Taken: 12.66s
Tokens Per Second: 27.64
```


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