Quick Start
Launch your first VM in minutes with the Heaptree Python SDK
Install
pip install htsdkGet Your API Key
- Log in to your dashboard: Dashboard
- Go to "API Keys" → "Create New API Key"
- 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_KEYVMs typically take 30–60 seconds to boot. If commands fail immediately after creation, wait briefly and retry.
Next Steps
- Authentication - Create an API key and set it up
- SDK Reference - Complete method docs
- Troubleshooting - Common issues and solutions
Need help? Email heatpreehq@gmail.com