Skip to main content

Deploy LLMs with dstack and vLLM on Vast.ai

dstack is an open-source GPU orchestration platform that simplifies deploying AI workloads across cloud providers. This guide shows you how to use dstack with Vast.ai as the backend to deploy language models using vLLM, with automated provisioning and cost controls.

Why Use dstack with Vast.ai?

  • Simplified Deployment: Define your model configuration in YAML, and dstack handles instance provisioning
  • Cost Controls: Set maximum hourly price limits and dstack finds the best available instances
  • OpenAI-Compatible API: vLLM provides a standard API that works with existing tools and SDKs
  • Automatic Proxy: dstack proxies requests to your service, handling authentication automatically

Prerequisites

  • A Vast.ai account with credits (Sign up here)
  • Your Vast.ai API key (from Account Settings)
  • Python 3.11 (dstack has compatibility issues with Python 3.14)

Hardware Requirements

This guide uses Qwen3-30B-A3B as an example. It’s a Mixture-of-Experts model with 30.5B total parameters.
  • VRAM Required: ~57GB for model weights + KV cache
  • Recommended GPU: H100 80GB or A100 80GB
Always check the model card on Hugging Face for VRAM requirements before deploying. A rough estimate: model parameters × 2 bytes for BF16 precision.

Setup

Step 1: Create Virtual Environment and Install dstack

Step 2: Configure dstack Server

Create the server configuration directory and file:
Create ~/.dstack/server/config.yml:
Replace YOUR_VASTAI_API_KEY with your actual Vast.ai API key.

Step 3: Start dstack Server

You’ll see output like:
Save the admin token from the output. You’ll need it for CLI access and API authentication.

Step 4: Configure CLI Access

In a new terminal, configure the CLI to connect to your dstack server:

Deploy a Model Service

Step 1: Create Service Configuration

Create serve-qwen.dstack.yml:
Key parameters:
  • type: service - Creates a long-running service with HTTP endpoint
  • python: "3.11" - Uses Python 3.11 for compatibility
  • commands - Install vLLM and start the model server
  • port: 8000 - The port vLLM serves on
  • resources.gpu: 80GB - Minimum GPU memory required
  • max_price: 2.50 - Maximum hourly cost in USD

Step 2: Deploy the Service

dstack will search for available instances and show you the options:

Step 3: Monitor Deployment

Check deployment status:
View deployment logs:
When ready, you’ll see in the logs:

Using the API

dstack automatically proxies requests to your service through the dstack server.

Chat Completions with cURL

Python Integration

Using the OpenAI SDK:

Streaming Responses

Cost Management

The max_price setting in your configuration caps your hourly cost. dstack will only provision instances at or below this price.

Managing Services

Stop a Service

This terminates the Vast.ai instance, stopping billing.

Useful Commands

Deploying Other Models

To deploy a different model, modify the configuration file:
Remember to:
  1. Check the model’s VRAM requirements on Hugging Face
  2. Set appropriate GPU memory in resources.gpu
  3. Adjust max_price based on GPU tier needed

Additional Resources