dstack AI Orchestration Engine

0.20.17 · active · verified Thu Apr 16

dstack is an open-source orchestration engine for running AI workloads on any cloud or on-premises. It provides a CLI and Python client for managing resources, services, and ML runs. Currently at version 0.20.17, the library maintains an active release schedule with frequent minor updates focusing on performance, new backend integrations, and feature enhancements.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to instantiate the dstack Python client and make a basic API call to verify connectivity and authentication by fetching the user's profile and listing projects. It assumes the dstack server URL and API key are configured via environment variables or the dstack CLI config file.

import os
from dstack.client import Client

# Configure dstack client via environment variables (DSTACK_URL, DSTACK_API_KEY)
# or the dstack config file (~/.dstack/config.yaml). For a runnable example,
# ensure these are set.
# Example: export DSTACK_URL="https://your-dstack-server.com"
# Example: export DSTACK_API_KEY="ds_your_api_key_here"

try:
    client = Client()
    # Attempt a simple API call to verify connection and authentication
    user_profile = client.get_profile() # Requires an authenticated client
    print(f"Successfully connected to dstack server as user: {user_profile.name} (ID: {user_profile.id})")

    # Example: List available projects
    projects = client.projects()
    print(f"Found {len(projects)} projects:")
    for project in projects:
        print(f"- {project.name} (ID: {project.id})")

except Exception as e:
    print(f"Error connecting to dstack or fetching data: {e}")
    print("Please ensure your dstack server URL (DSTACK_URL) and API Key (DSTACK_API_KEY) are correctly configured in your environment or dstack config file.")

view raw JSON →