heaptree-logo
Heaptree

Quick Start

Launch your first VM in minutes with the Heaptree Python SDK

Install

pip install htsdk

Get Your API Key

  1. Log in to your dashboard: Dashboard
  2. Go to "API Keys" → "Create New API Key"
  3. Copy the key and set it as an environment variable:
HEAPTREE_API_KEY="your-api-key"

For more detailed information, visit the Authentication guide.

Create Your First VM

import os
from heaptree import Heaptree

# Initialize client
client = Heaptree(api_key=os.getenv("HEAPTREE_API_KEY"))

# Create a VM
result = client.create_node() # alive for 5 minutes by default

print(f"VM Created: {result.node_id}")

# Run a command
execution = client.run_command(
    node_id=result.node_id,
    command="echo 'Hello from Heaptree!'"
)

print(f"Output: {execution.output}")

# Clean up
client.terminate(result.node_id)

What Just Happened?

  • Created a VM in seconds with one line of code
  • Ran a command remotely on the VM
  • Cleaned up resources automatically

Common Operations

Upload a File

client.upload(
    node_id=result.node_id,
    file_path="./script.py",
    destination_path="/home/ubuntu/script.py"
)

Execute Python Code

code_result = client.run_code(
    node_id=result.node_id,
    lang=Language.PYTHON,
    code="print('Hello World')"
)

print(code_result.output)

Troubleshooting

Authentication failed? Verify your API key is set:

echo $HEAPTREE_API_KEY

VMs typically take 30–60 seconds to boot. If commands fail immediately after creation, wait briefly and retry.

Next Steps

Need help? Email heatpreehq@gmail.com