Rent GPU instances from the Hyperbolic marketplace and manage compute resources
The rent_compute tool allows your AI agent to rent GPU instances from the Hyperbolic marketplace. This enables agents to dynamically provision compute resources for training models, running inference, or other GPU-intensive tasks.
from hyperbolic_agentkit_core.actions import RentComputeAction# Initialize the actionrent_action = RentComputeAction()# Rent 2 GPUs from a specific noderesult = rent_action.func( cluster_name="us-east-1-cluster", node_name="node-abc123", gpu_count="2")print(result)
from hyperbolic_agentkit_core.actions import ( GetAvailableGpusAction, RentComputeAction, GetGpuStatusAction)import jsonimport time# Step 1: Get available GPUsget_gpus = GetAvailableGpusAction()available = get_gpus.func()print(available)# Step 2: Parse the output and select a GPU# (In a real scenario, you'd parse the text output)cluster_name = "us-east-1-cluster"node_name = "node-abc123"gpu_count = "2"# Step 3: Rent the computerent = RentComputeAction()result = rent.func( cluster_name=cluster_name, node_name=node_name, gpu_count=gpu_count)instance_data = json.loads(result)print(f"Rented instance: {instance_data['instance_id']}")# Step 4: Wait for instance to be readyget_status = GetGpuStatusAction()while True: status = get_status.func() status_data = json.loads(status) if isinstance(status, str) else status # Find our instance in the status list our_instance = None if isinstance(status_data, dict) and "instances" in status_data: for inst in status_data["instances"]: if inst.get("instance_id") == instance_data["instance_id"]: our_instance = inst break if our_instance and our_instance.get("status") == "running": print(f"Instance is ready!") print(f"SSH: {our_instance.get('ssh_command')}") break print("Instance is starting... waiting 5 seconds") time.sleep(5)