In this example we are going to use vLLM to host an API for deepseek-ai/DeepSeek-R1-Distill-Qwen-7B on Beam.

View the Code

See the code for this example on Github.

Initial Setup

First, clone the vLLM example to your computer.

$ 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:

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

$ 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

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.

**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