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:
Field | Type | Required | Description |
---|---|---|---|
name | string | Yes | The name of the instance |
imageId | string | Yes | The ID of the image to use for the instance |
instanceTypeId | string | Yes | The ID of the instance type |
region | string | Yes | The ID of the region where the instance will be launched |
billing | object | Yes | Billing configuration for the instance |
remoteStorages | array | Yes | Array of remote storage configurations |
instanceConfiguration | object | Yes | Additional instance configuration options |
isSpotInstance | boolean | No | Whether this is a spot instance (default: false) |
nodePorts | array | Yes | Array of node port configurations |
Billing Configuration
The billing
object contains:
Field | Type | Required | Description |
---|---|---|---|
chargeMode | string | Yes | Billing mode ("tidePerHour", "perHour", "perDay", "perWeek", "perMonth") |
duration | number | Yes | If 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:
Field | Type | Required | Description |
---|---|---|---|
mountPath | string | Yes | Path to mount in the instance |
remoteStorageName | string | Yes | Name of the remote storage |
remoteStorageId | string | Yes | Unique ID of the remote storage |
type | string | Yes | Storage type (e.g., highspeedstorage, filesystem) |
Instance Configuration
The instanceConfiguration
object contains:
Field | Type | Required | Description |
---|---|---|---|
extraDataDiskSizeDB | number | No | Extra data disk size in GB (default: 0) |
enableCommonData | boolean | Yes | Enable common data storage (default: false) |
enableDocker | boolean | Yes | Enable Docker support (default: false) |
dockerStorageSize | number | No | Docker storage size in GB (default: 0) |
initScript | string | Yes | Initialization 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"
}