> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tensorone.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Start Cluster

> Start stopped GPU clusters with configuration options and monitoring capabilities

## Overview

The Start Cluster endpoint allows you to start previously stopped GPU clusters, optionally updating configuration settings during startup. This enables cost-effective cluster management by stopping clusters when not in use and quickly resuming work when needed.

## Endpoint

```bash curl
POST https://api.tensorone.ai/v1/clusters/{cluster_id}/start
```

## Path Parameters

| Parameter | Type | Required | Description |
| - | - | - | - |
| `cluster_id` | string | Yes | Unique cluster identifier |

## Request Body

| Parameter | Type | Required | Description |
| - | - | - | - |
| `wait_for_ready` | boolean | No | Wait for cluster to be fully ready before returning (default: false) |
| `timeout_minutes` | integer | No | Maximum wait time in minutes (default: 10, max: 30) |
| `update_configuration` | object | No | Configuration updates to apply during startup |
| `restore_from_snapshot` | string | No | Snapshot ID to restore from |
| `environment_updates` | object | No | Environment variable updates |
| `port_mapping_updates` | array | No | Port mapping changes |
| `auto_terminate_updates` | object | No | Auto-termination setting updates |

### Configuration Updates

```json
{
  "update_configuration": {
    "cpu_cores": 64,              // Update CPU allocation
    "memory_gb": 512,             // Update memory allocation
    "storage_gb": 2000,           // Expand storage (cannot shrink)
    "docker_image": "new_image",  // Update Docker image
    "gpu_count": 8                // Update GPU count (if available)
  }
}
```

## Request Examples

```bash curl
# Basic cluster start
curl -X POST "https://api.tensorone.ai/v1/clusters/cluster_abc123/start" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "wait_for_ready": true,
    "timeout_minutes": 15
  }'

# Start with configuration updates
curl -X POST "https://api.tensorone.ai/v1/clusters/cluster_abc123/start" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "wait_for_ready": true,
    "update_configuration": {
      "memory_gb": 512,
      "docker_image": "pytorch/pytorch:2.2-cuda12.1-devel"
    },
    "environment_updates": {
      "BATCH_SIZE": "64",
      "LEARNING_RATE": "0.001"
    },
    "auto_terminate_updates": {
      "enabled": true,
      "idle_minutes": 30
    }
  }'

# Start and restore from snapshot
curl -X POST "https://api.tensorone.ai/v1/clusters/cluster_abc123/start" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "wait_for_ready": false,
    "restore_from_snapshot": "snap_xyz789",
    "port_mapping_updates": [
      {
        "internal_port": 8888,
        "external_port": 0,
        "protocol": "tcp",
        "description": "Jupyter Lab"
      }
    ]
  }'
```

```python Python
import requests
import time

def start_cluster(cluster_id, wait_for_ready=True):
    """Start a cluster and optionally wait for it to be ready"""
    
    response = requests.post(
        f"https://api.tensorone.ai/v1/clusters/{cluster_id}/start",
        headers={
            "Authorization": "Bearer YOUR_API_KEY",
            "Content-Type": "application/json"
        },
        json={
            "wait_for_ready": wait_for_ready,
            "timeout_minutes": 15
        }
    )
    
    result = response.json()
    
    if result["success"]:
        print(f"Cluster {cluster_id} start initiated")
        if wait_for_ready:
            print(f"Cluster is ready at: {result['data']['proxy_url']}")
    
    return result

def start_cluster_with_updates(cluster_id, config_updates):
    """Start cluster with configuration updates"""
    
    payload = {
        "wait_for_ready": True,
        "timeout_minutes": 20,
        "update_configuration": config_updates.get("hardware", {}),
        "environment_updates": config_updates.get("environment", {}),
        "auto_terminate_updates": config_updates.get("auto_terminate", {})
    }
    
    response = requests.post(
        f"https://api.tensorone.ai/v1/clusters/{cluster_id}/start",
        headers={
            "Authorization": "Bearer YOUR_API_KEY",
            "Content-Type": "application/json"
        },
        json=payload
    )
    
    return response.json()

# Example: Start training cluster with updated configuration
training_updates = {
    "hardware": {
        "memory_gb": 256,
        "docker_image": "tensorone/pytorch:2.2-cuda12.1"
    },
    "environment": {
        "WORLD_SIZE": "4",
        "MASTER_ADDR": "localhost",
        "MASTER_PORT": "12355"
    },
    "auto_terminate": {
        "enabled": True,
        "idle_minutes": 60,
        "cost_limit_usd": 200.0
    }
}

result = start_cluster_with_updates("cluster_training_01", training_updates)
```

```javascript JavaScript
// Basic cluster start
async function startCluster(clusterId, waitForReady = true) {
  const response = await fetch(`https://api.tensorone.ai/v1/clusters/${clusterId}/start`, {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer YOUR_API_KEY',
      'Content-Type': 'application/json'
    },
    body: JSON.stringify({
      wait_for_ready: waitForReady,
      timeout_minutes: 15
    })
  });
  
  const result = await response.json();
  
  if (result.success) {
    console.log(`Cluster ${clusterId} started successfully`);
    if (waitForReady) {
      console.log(`Access URL: ${result.data.proxy_url}`);
    }
  }
  
  return result;
}

// Start cluster with resource scaling
async function startAndScaleCluster(clusterId, scalingConfig) {
  const startConfig = {
    wait_for_ready: true,
    timeout_minutes: 20,
    update_configuration: {
      cpu_cores: scalingConfig.cpuCores,
      memory_gb: scalingConfig.memoryGb,
      gpu_count: scalingConfig.gpuCount
    },
    environment_updates: scalingConfig.environmentVars || {},
    port_mapping_updates: scalingConfig.portMappings || []
  };
  
  try {
    const response = await fetch(`https://api.tensorone.ai/v1/clusters/${clusterId}/start`, {
      method: 'POST',
      headers: {
        'Authorization': 'Bearer YOUR_API_KEY',
        'Content-Type': 'application/json'
      },
      body: JSON.stringify(startConfig)
    });
    
    const result = await response.json();
    
    if (!result.success) {
      throw new Error(`Failed to start cluster: ${result.error.message}`);
    }
    
    return {
      clusterId: result.data.id,
      status: result.data.status,
      proxyUrl: result.data.proxy_url,
      sshConnection: result.data.ssh_connection,
      estimatedCost: result.data.cost.hourly_rate
    };
    
  } catch (error) {
    console.error('Error starting cluster:', error);
    throw error;
  }
}

// Utility function to start multiple clusters in parallel
async function startMultipleClusters(clusterIds, config = {}) {
  const startPromises = clusterIds.map(clusterId => 
    startCluster(clusterId, config.waitForReady || false)
  );
  
  const results = await Promise.allSettled(startPromises);
  
  const successful = results
    .filter(result => result.status === 'fulfilled' && result.value.success)
    .map(result => result.value.data);
    
  const failed = results
    .filter(result => result.status === 'rejected' || !result.value.success)
    .map((result, index) => ({
      clusterId: clusterIds[index],
      error: result.status === 'rejected' ? result.reason : result.value.error
    }));
  
  return { successful, failed };
}
```

## Response Schema

```json Success Response (Immediate)
{
  "success": true,
  "data": {
    "id": "cluster_abc123",
    "name": "ml-training-cluster",
    "status": "starting",
    "start_initiated_at": "2024-01-15T16:00:00Z",
    "estimated_ready_at": "2024-01-15T16:05:00Z",
    "configuration_updates_applied": [
      "memory_gb: 256 -> 512",
      "docker_image: pytorch:2.1 -> pytorch:2.2"
    ],
    "startup_progress": {
      "phase": "initializing",
      "percentage": 15,
      "current_step": "Allocating resources",
      "steps_completed": 2,
      "total_steps": 8
    },
    "cost": {
      "new_hourly_rate": 12.50,
      "previous_hourly_rate": 8.50,
      "rate_change_reason": "Memory upgrade"
    }
  },
  "meta": {
    "request_id": "req_start_123",
    "wait_for_ready": false
  }
}
```

```json Success Response (Wait for Ready)
{
  "success": true,
  "data": {
    "id": "cluster_abc123",
    "name": "ml-training-cluster",
    "status": "running",
    "start_initiated_at": "2024-01-15T16:00:00Z",
    "ready_at": "2024-01-15T16:04:32Z",
    "startup_duration_seconds": 272,
    "configuration": {
      "gpu_type": "A100",
      "gpu_count": 4,
      "cpu_cores": 64,
      "memory_gb": 512,
      "storage_gb": 1000
    },
    "network": {
      "proxy_url": "https://cluster-abc123.tensorone.ai",
      "ssh_connection": {
        "host": "ssh-abc123.tensorone.ai",
        "port": 22,
        "username": "root",
        "connection_string": "ssh root@ssh-abc123.tensorone.ai",
        "status": "connected"
      },
      "port_mappings": [
        {
          "internal_port": 8888,
          "external_port": 32001,
          "protocol": "tcp",
          "description": "Jupyter Lab",
          "url": "https://cluster-abc123.tensorone.ai:32001",
          "status": "active"
        }
      ]
    },
    "cost": {
      "hourly_rate": 12.50,
      "currency": "USD",
      "billing_started_at": "2024-01-15T16:04:32Z"
    },
    "auto_terminate": {
      "enabled": true,
      "idle_minutes": 30,
      "estimated_termination": "2024-01-15T16:34:32Z"
    },
    "health_checks": {
      "gpu_health": "healthy",
      "storage_health": "healthy",
      "network_health": "healthy",
      "docker_health": "healthy"
    }
  },
  "meta": {
    "request_id": "req_start_123",
    "wait_for_ready": true,
    "total_wait_time_seconds": 272
  }
}
```

## Startup Progress Tracking

When `wait_for_ready` is false, you can poll the cluster status to track startup progress:

```python
def track_startup_progress(cluster_id):
    """Track cluster startup progress with real-time updates"""
    
    import time
    
    while True:
        response = requests.get(
            f"https://api.tensorone.ai/v1/clusters/{cluster_id}",
            headers={"Authorization": f"Bearer {API_KEY}"}
        )
        
        cluster = response.json()["data"]
        status = cluster["status"]
        
        if status == "running":
            print(f"✅ Cluster {cluster_id} is ready!")
            print(f"Access URL: {cluster['network']['proxy_url']}")
            break
        elif status == "starting":
            # Show progress if available
            if "startup_progress" in cluster:
                progress = cluster["startup_progress"]
                print(f"🔄 {progress['current_step']} ({progress['percentage']}%)")
            else:
                print(f"🔄 Starting cluster... (Status: {status})")
        elif status == "error":
            print(f"❌ Cluster startup failed: {cluster.get('error_message', 'Unknown error')}")
            break
        
        time.sleep(10)  # Check every 10 seconds
```

## Use Cases

### Development Workflow

Start development clusters when team members begin work.

```python
def start_dev_environment(user_id, project_id):
    """Start a development environment for a user"""
    
    # Find user's development cluster
    clusters_response = requests.get(
        "https://api.tensorone.ai/v1/clusters",
        headers={"Authorization": f"Bearer {API_KEY}"},
        params={
            "project_id": project_id,
            "search": f"dev-{user_id}",
            "status": "stopped"
        }
    )
    
    clusters = clusters_response.json()["data"]["clusters"]
    
    if not clusters:
        return {"error": "No development cluster found for user"}
    
    cluster_id = clusters[0]["id"]
    
    # Start with updated environment
    start_config = {
        "wait_for_ready": True,
        "timeout_minutes": 10,
        "environment_updates": {
            "USER_ID": user_id,
            "PROJECT_ID": project_id,
            "WORKSPACE": f"/workspace/{user_id}"
        },
        "auto_terminate_updates": {
            "enabled": True,
            "idle_minutes": 120  # 2 hours for dev work
        }
    }
    
    response = requests.post(
        f"https://api.tensorone.ai/v1/clusters/{cluster_id}/start",
        headers={"Authorization": f"Bearer {API_KEY}"},
        json=start_config
    )
    
    return response.json()
```

### Training Job Resumption

Resume training jobs from checkpoints with updated configurations.

```javascript
async function resumeTrainingJob(jobId, checkpointPath, newConfig = {}) {
  // Find training cluster for this job
  const clustersResponse = await fetch(`https://api.tensorone.ai/v1/clusters?search=training-${jobId}&status=stopped`, {
    headers: { 'Authorization': 'Bearer ' + API_KEY }
  });
  
  const clusters = await clustersResponse.json();
  
  if (!clusters.success || clusters.data.clusters.length === 0) {
    throw new Error(`No training cluster found for job ${jobId}`);
  }
  
  const clusterId = clusters.data.clusters[0].id;
  
  const startConfig = {
    wait_for_ready: true,
    timeout_minutes: 15,
    environment_updates: {
      RESUME_FROM_CHECKPOINT: checkpointPath,
      JOB_ID: jobId,
      ...newConfig.environment
    },
    update_configuration: {
      ...newConfig.hardware
    },
    auto_terminate_updates: {
      enabled: true,
      cost_limit_usd: newConfig.costLimit || 500.0,
      idle_minutes: 30
    }
  };
  
  const response = await fetch(`https://api.tensorone.ai/v1/clusters/${clusterId}/start`, {
    method: 'POST',
    headers: {
      'Authorization': 'Bearer ' + API_KEY,
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(startConfig)
  });
  
  const result = await response.json();
  
  if (result.success) {
    return {
      clusterId: result.data.id,
      jobId: jobId,
      accessUrl: result.data.network.proxy_url,
      sshCommand: result.data.network.ssh_connection.connection_string,
      estimatedCost: result.data.cost.hourly_rate
    };
  }
  
  throw new Error(`Failed to resume training job: ${result.error.message}`);
}
```

### Scheduled Cluster Activation

Start clusters on a schedule for batch processing jobs.

```python
def scheduled_cluster_start(cluster_configs, schedule_time=None):
    """Start multiple clusters for scheduled batch jobs"""
    
    import schedule
    import threading
    
    def start_batch_clusters():
        results = []
        
        for config in cluster_configs:
            cluster_id = config["cluster_id"]
            updates = config.get("updates", {})
            
            start_payload = {
                "wait_for_ready": False,
                "update_configuration": updates.get("hardware", {}),
                "environment_updates": {
                    "BATCH_JOB_ID": config.get("job_id"),
                    "START_TIME": datetime.now().isoformat(),
                    **updates.get("environment", {})
                },
                "auto_terminate_updates": {
                    "enabled": True,
                    "max_runtime_hours": config.get("max_runtime_hours", 8),
                    "cost_limit_usd": config.get("cost_limit", 100.0)
                }
            }
            
            response = requests.post(
                f"https://api.tensorone.ai/v1/clusters/{cluster_id}/start",
                headers={"Authorization": f"Bearer {API_KEY}"},
                json=start_payload
            )
            
            results.append({
                "cluster_id": cluster_id,
                "job_id": config.get("job_id"),
                "success": response.json().get("success", False),
                "response": response.json()
            })
        
        return results
    
    if schedule_time:
        schedule.every().day.at(schedule_time).do(start_batch_clusters)
        
        def run_scheduler():
            while True:
                schedule.run_pending()
                time.sleep(60)
        
        scheduler_thread = threading.Thread(target=run_scheduler)
        scheduler_thread.daemon = True
        scheduler_thread.start()
    else:
        return start_batch_clusters()
```

## Error Handling

```json Cluster Not Stopped
{
  "success": false,
  "error": {
    "code": "INVALID_STATE",
    "message": "Cluster is not in a stopped state",
    "details": {
      "current_status": "running",
      "required_status": "stopped",
      "suggestion": "Stop the cluster first or wait for it to finish current operations"
    }
  }
}
```

```json Resource Unavailable
{
  "success": false,
  "error": {
    "code": "RESOURCE_UNAVAILABLE",
    "message": "Requested GPU configuration is not available",
    "details": {
      "requested_gpu_count": 8,
      "available_gpu_count": 4,
      "gpu_type": "A100",
      "region": "us-west-2",
      "estimated_availability": "2024-01-15T18:00:00Z"
    }
  }
}
```

```json Configuration Error
{
  "success": false,
  "error": {
    "code": "CONFIGURATION_ERROR",
    "message": "Invalid configuration updates provided",
    "details": {
      "storage_gb": "Cannot reduce storage size from 1000GB to 500GB",
      "docker_image": "Image 'invalid/image:tag' not found or access denied"
    }
  }
}
```

```json Timeout Error
{
  "success": false,
  "error": {
    "code": "STARTUP_TIMEOUT",
    "message": "Cluster did not start within the specified timeout",
    "details": {
      "timeout_minutes": 15,
      "current_status": "starting",
      "startup_progress": {
        "phase": "configuring_network",
        "percentage": 75
      },
      "suggestion": "Try again or contact support if the issue persists"
    }
  }
}
```

## Security Considerations

* **State Validation**: Ensure clusters are in the correct state before starting
* **Configuration Updates**: Validate configuration changes don't compromise security
* **Resource Limits**: Monitor resource allocation to prevent quota violations
* **Access Control**: Verify permissions for configuration updates

## Best Practices

1. **Startup Monitoring**: Always monitor startup progress for production clusters
2. **Configuration Validation**: Test configuration updates in development first
3. **Cost Management**: Set appropriate auto-termination limits
4. **Resource Planning**: Consider resource availability during peak hours
5. **Backup Strategy**: Use snapshots before major configuration changes
6. **Error Handling**: Implement proper error handling and retry logic


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.