Skip to main content

Launch an Instance

Launch a new instance.

/instance/create

Authorization

You can find the AccessToken in the Request Header, or copy it from the web page(copy Auth Token). This token is generated each time you log in and will expire after one day.

You can also request the login api to get another token. See login api.

The AccessToken should be included in the request as a cookie. In the cURL example below, you can see how the token is passed using the -b flag:

-b 'AccessToken=your_token_here'

Note: Replace your_token_here with your actual AccessToken. The token is a JWT (JSON Web Token) that contains your authentication information and permissions.

Request Body

You can export request body from the "launch instance" page. Simply complete your instance configuration to export the data.

The detailed fields of request body are listed as follows:

FieldTypeRequiredDescription
namestringYesThe name of the instance
imageIdstringYesThe ID of the image to use for the instance
instanceTypeIdstringYesThe ID of the instance type
regionstringYesThe ID of the region where the instance will be launched
billingobjectYesBilling configuration for the instance
remoteStoragesarrayYesArray of remote storage configurations
instanceConfigurationobjectYesAdditional instance configuration options
isSpotInstancebooleanNoWhether this is a spot instance (default: false)
nodePortsarrayYesArray of node port configurations

Billing Configuration

The billing object contains:

FieldTypeRequiredDescription
chargeModestringYesBilling mode ("tidePerHour", "perHour", "perDay", "perWeek", "perMonth")
durationnumberYesIf choose "perDay", "perWeek", "perMonth", duration represents the subscription period (e.g., duration: 3 with perWeek means 3 weeks) If choose "perHour" or "tidePerHour", duration should be 1.

RemoteStorages Configuration

Each object in the remoteStorages array contains the following fields:

FieldTypeRequiredDescription
mountPathstringYesPath to mount in the instance
remoteStorageNamestringYesName of the remote storage
remoteStorageIdstringYesUnique ID of the remote storage
typestringYesStorage type (e.g., highspeedstorage, filesystem)

Instance Configuration

The instanceConfiguration object contains:

FieldTypeRequiredDescription
extraDataDiskSizeDBnumberNoExtra data disk size in GB (default: 0)
enableCommonDatabooleanYesEnable common data storage (default: false)
enableDockerbooleanYesEnable Docker support (default: false)
dockerStorageSizenumberNoDocker storage size in GB (default: 0)
initScriptstringYesInitialization script to run on startup

Example Request

{
"name": "example-instance",
"imageId": "7a81788c-xxxx-xxxx-xxxx-2409e3c8150c",
"instanceTypeId": "dc25f5be-xxxx-xxxx-xxxx-5030e3358c41",
"region": "fce31a0c-xxxx-xxxx-xxxx-41caa1bdd251",
"billing": {
"chargeMode": "perHour",
"duration": 1
},
"remoteStorages": [
{
"mountPath": "/root/highspeedstorage/example-volume",
"remoteStorageName": "example-volume",
"remoteStorageId": "f6a6345e-xxxx-xxxx-xxxx-e52e330cfaec",
"type": "highspeedstorage"
}
],
"instanceConfiguration": {
"extraDataDiskSizeDB": 0,
"enableCommonData": false,
"enableDocker": true,
"dockerStorageSize": 50,
"initScript": ""
},
"isSpotInstance": false,
"nodePorts": [
7891,
7892
]
}

cURL Example

curl 'https://hpc-ai.com/api/instance/create' \
-H 'content-type: application/json' \
-b 'AccessToken=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOlsicGxhdGZvcm0uY29sb3NzYWxhaS5jb20iXSwiZXhwIjoxNzUxNTI5Njg2LCJncm91cCI6WyJhZG1pbiJdLCJpYXQiOjE3NTE0NDMyODYsImlzcyI6ImhwY2FpdGVjaC5jb20iLCJzdWIiOiIwOGY2ZjI2MS1hNzY2LTQ2M2UtOGJhNC04NWU2YWUzMmY0OTIifQ.pnTtcw2Spns2Xi_knR_LclTt4eJGUK-lDzIJxHEDi13p7gACVKpJz548QZGq891lg7jpiKpn4QJRgNYxrZQmSThmZVSbJnwmttz01ijy1cGKuq61UI3zaHLPIyVDhqVVjuch0KedFFC9ahr4jSPf6-7ibgaTN7ozHWsMkLKjDyDUPjYfAdfmIz2dtSxJ0WBC6-c4BkwcKOCjHj3eye9BI9c74JUOTVNinwIoKdOzdF5mqI83rVuVpS_7lSAfrsdscqFXRiGtHcHLrb9nLs2Jcv5IkIdnKo5zzRNdpKWYhQWPYKowSlSWDa5eZv-hw3EsyhiQAByZ5x6yYYn_R5Hxxxx' \
--data-raw '{"name":"example-instance","imageId":"7a81788c-xxxx-xxxx-xxxx-2409e3c8150c","instanceTypeId":"c531be90-xxxx-xxxx-xxxx-59d3d911e29e","region":"fce31a0c-xxxx-xxxx-xxxx-41caa1bdd251","billing":{"chargeMode":"perHour","duration":1},"remoteStorages":[],"instanceConfiguration":{"enableCommonData":false,"enableDocker":false, "initScript": ""},"nodePorts":[]}'

Example Response

Success Response

{
"instanceId": "notebook-78d36d6a-xxxx-xxxx-xxxx-eea5891c2019"
}

Error Response

{
"message": "field \"instanceConfiguration.enableDocker\" is not set"
}
{
"code": -1,
"message": "Not logged in or login expired, please log in again"
}