> ## 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.

# GraphQL Clusters Management

> Complete GraphQL API guide for managing Tensor One clusters including creation, startup, shutdown, monitoring, and GPU type queries with curl examples and authentication setup.

***

## Cluster Management via GraphQL

Use the **Tensor One GraphQL API** to programmatically manage Clusters, including creation, startup, shutdown, and monitoring.

***

## Authentication

All GraphQL requests must include an **API Key** for authentication.

* Get your API key in **Settings** from the [Tensor One Web](https://tensorone.ai)
* Append it to requests as a query parameter:

```bash
https://api.tensorone.ai/graphql?api_key=${YOUR_API_KEY}
```

For full API specs, see the [GraphQL Reference](https://docs.tensorone.ai/developer/sdks/graphql-configurations.md).

***

## Cluster Resource Overview

A Cluster in Tensor One includes:

* **0 or more GPUs** - Optional, but needed for GPU-accelerated workloads
* **vCPU & RAM** - Required compute resources
* **Container Disk** - Temporary, billed **only while running**
* **Instance Volume** - Persistent, billed **even when stopped**

***

## Creating Clusters

### On-Demand Cluster

```bash
curl --request POST \
--header 'content-type: application/json' \
--url 'https://api.tensorone.ai/graphql?api_key=${YOUR_API_KEY}' \
--data '{
  "query": "mutation {
    clusterFindAndDeployOnDemand(input: {
      cloudType: ALL,
      gpuCount: 1,
      volumeInGb: 40,
      containerDiskInGb: 40,
      minVcpuCount: 2,
      minMemoryInGb: 15,
      gpuTypeId: \"NVIDIA RTX A6000\",
      name: \"Tensor One Tensorflow\",
      imageName: \"tensorone/tensorflow\",
      dockerArgs: \"\",
      ports: \"8888/http\",
      volumeMountPath: \"/workspace\",
      env: [{ key: \"JUPYTER_PASSWORD\", value: \"your_password\" }]
    }) {
      id imageName env machineId machine { clusterHostId }
    }
  }"
}'
```

### Spot Cluster

```bash
curl --request POST \
--header 'content-type: application/json' \
--url 'https://api.tensorone.ai/graphql?api_key=${YOUR_API_KEY}' \
--data '{
  "query": "mutation {
    clusterRentInterruptable(input: {
      bidPerGpu: 0.2,
      cloudType: SECURE,
      gpuCount: 1,
      volumeInGb: 40,
      containerDiskInGb: 40,
      minVcpuCount: 2,
      minMemoryInGb: 15,
      gpuTypeId: \"NVIDIA RTX A6000\",
      name: \"Tensor One Pytorch\",
      imageName: \"tensorone/pytorch\",
      dockerArgs: \"\",
      ports: \"8888/http\",
      volumeMountPath: \"/workspace\",
      env: [{ key: \"JUPYTER_PASSWORD\", value: \"your_password\" }]
    }) {
      id imageName env machineId machine { clusterHostId }
    }
  }"
}'
```

***

## Starting Clusters

### Start On-Demand Cluster

```bash
curl --request POST \
--header 'content-type: application/json' \
--url 'https://api.tensorone.ai/graphql?api_key=${YOUR_API_KEY}' \
--data '{
  "query": "mutation {
    clusterResume(input: {
      clusterId: \"your_cluster_id\",
      gpuCount: 1
    }) {
      id desiredStatus imageName env machineId machine { clusterHostId }
    }
  }"
}'
```

### Start Spot Cluster

```bash
curl --request POST \
--header 'content-type: application/json' \
--url 'https://api.tensorone.ai/graphql?api_key=${YOUR_API_KEY}' \
--data '{
  "query": "mutation {
    clusterBidResume(input: {
      clusterId: \"your_cluster_id\",
      bidPerGpu: 0.2,
      gpuCount: 1
    }) {
      id desiredStatus imageName env machineId machine { clusterHostId }
    }
  }"
}'
```

***

## Stopping Clusters

```bash
curl --request POST \
--header 'content-type: application/json' \
--url 'https://api.tensorone.ai/graphql?api_key=${YOUR_API_KEY}' \
--data '{
  "query": "mutation {
    clusterStop(input: {
      clusterId: \"your_cluster_id\"
    }) {
      id desiredStatus
    }
  }"
}'
```

***

## Listing Clusters

### List All Clusters

```bash
curl --request POST \
--header 'content-type: application/json' \
--url 'https://api.tensorone.ai/graphql?api_key=${YOUR_API_KEY}' \
--data '{
  "query": "query clusters {
    myself {
      clusters {
        id name
        runtime {
          uptimeInSeconds
          ports {
            ip isIpPublic privatePort publicPort type
          }
          gpus {
            id gpuUtilPercent memoryUtilPercent
          }
          container {
            cpuPercent memoryPercent
          }
        }
      }
    }
  }"
}'
```

### Get Cluster by ID

```bash
curl --request POST \
--header 'content-type: application/json' \
--url 'https://api.tensorone.ai/graphql?api_key=${YOUR_API_KEY}' \
--data '{
  "query": "query cluster {
    cluster(input: {
      clusterId: \"your_cluster_id\"
    }) {
      id name
      runtime {
        uptimeInSeconds
        ports {
          ip isIpPublic privatePort publicPort type
        }
        gpus {
          id gpuUtilPercent memoryUtilPercent
        }
        container {
          cpuPercent memoryPercent
        }
      }
    }
  }"
}'
```

***

## GPU Type Queries

### List All GPU Types

```bash
curl --request POST \
--header 'content-type: application/json' \
--url 'https://api.tensorone.ai/graphql?api_key=${YOUR_API_KEY}' \
--data '{
  "query": "query GpuTypes {
    gpuTypes {
      id displayName memoryInGb
    }
  }"
}'
```

### Get GPU Type by ID

```bash
curl --request POST \
--header 'content-type: application/json' \
--url 'https://api.tensorone.ai/graphql?api_key=${YOUR_API_KEY}' \
--data '{
  "query": "query GpuTypes {
    gpuTypes(input: { id: \"NVIDIA GeForce RTX 3090\" }) {
      id displayName memoryInGb
      secureCloud
      communityCloud
      lowestPrice(input: { gpuCount: 1 }) {
        minimumBidPrice
        uninterruptablePrice
      }
    }
  }"
}'
```


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