Create an instance
Creates an instance of a preset with an image, and starts it. The
preset sets the region, location and hardware, and the instance is
billed at that preset’s price, or at your organization’s discounted
rate when that is lower. hourly_rate in the response is the rate
billed. Your account needs enough credit for one hour of the preset,
unless it is invoiced.
Creates are not idempotent and names are not unique. Each
successful call creates and bills a new instance, even with the same
body. If a create answers 500, 503 or 504, or the connection
drops, the instance may or may not exist: list your instances with
GET /instances before retrying.
Look the preset up with GET /presets before each create rather than
storing its id: a preset can be retired, which answers 404, or
edited in place to a different size or price. Find it again by sku,
region and location, and check the size and hourly_rate in the
response.
The instance gets the SSH key you registered last, whether through
POST /ssh-keys or in the console. Without a key, the call answers
404.
Give image_type and image_id as GET /images lists them. The
image must suit the preset: for a virtual machine, a GPU preset needs
an image with gpu_supported; the preset must meet the image’s
min_disk_gb and min_memory_gb; and the location must allow the
image’s os_family. Otherwise the call answers 400, with a fixed
message that does not say which rule failed. Windows images cannot be
created through the API in this release and are refused too.
Connection details are not part of the API in this release: neither
this response nor GET /instances/{id} carries a host or port. Find
them on the instance in the Hive Compute console.
Ports, environment variables, tags and a startup script are not part of this release.
curl --request POST \
--url https://api.hivecompute.ai/v1/instances \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "training-run-1",
"preset_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"image_id": "ubuntu24.04"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'training-run-1',
preset_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
image_id: 'ubuntu24.04'
})
};
fetch('https://api.hivecompute.ai/v1/instances', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.hivecompute.ai/v1/instances"
payload = {
"name": "training-run-1",
"preset_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"image_id": "ubuntu24.04"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"instance": {
"instance_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "training-run-4",
"status": "CREATED",
"region": "france-2",
"gpu_type": "RTX 4090",
"size": "8 x GPU",
"cpu_count": 123,
"resources": "<string>",
"bandwidth": 123,
"storage_used_gb": 123,
"hourly_rate": 123,
"current_cost": 123,
"total_cost_incurred": 123,
"total_runtime_hours": 123,
"ttl_remaining_hours": 123,
"started_at": "2023-11-07T05:31:56Z",
"terminated_at": "2023-11-07T05:31:56Z",
"termination_reason": "USER_INITIATED",
"guest_ready": "READY",
"guest_ready_reason": "<string>"
}
}{
"error": {
"code": "VALIDATION_ERROR",
"message": "[{\"property\":\"size\",\"constraints\":[\"size must not be greater than 200\"]}]",
"request_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Missing API token",
"request_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "TOO_MANY_REQUESTS",
"message": "Too Many Requests",
"request_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"request_id": "<string>"
}
}Authorizations
Body
Was this page helpful?
curl --request POST \
--url https://api.hivecompute.ai/v1/instances \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"name": "training-run-1",
"preset_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"image_id": "ubuntu24.04"
}
'const options = {
method: 'POST',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
name: 'training-run-1',
preset_id: '3c90c3cc-0d44-4b50-8888-8dd25736052a',
image_id: 'ubuntu24.04'
})
};
fetch('https://api.hivecompute.ai/v1/instances', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));import requests
url = "https://api.hivecompute.ai/v1/instances"
payload = {
"name": "training-run-1",
"preset_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"image_id": "ubuntu24.04"
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.post(url, json=payload, headers=headers)
print(response.text){
"instance": {
"instance_id": "3c90c3cc-0d44-4b50-8888-8dd25736052a",
"name": "training-run-4",
"status": "CREATED",
"region": "france-2",
"gpu_type": "RTX 4090",
"size": "8 x GPU",
"cpu_count": 123,
"resources": "<string>",
"bandwidth": 123,
"storage_used_gb": 123,
"hourly_rate": 123,
"current_cost": 123,
"total_cost_incurred": 123,
"total_runtime_hours": 123,
"ttl_remaining_hours": 123,
"started_at": "2023-11-07T05:31:56Z",
"terminated_at": "2023-11-07T05:31:56Z",
"termination_reason": "USER_INITIATED",
"guest_ready": "READY",
"guest_ready_reason": "<string>"
}
}{
"error": {
"code": "VALIDATION_ERROR",
"message": "[{\"property\":\"size\",\"constraints\":[\"size must not be greater than 200\"]}]",
"request_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "Missing API token",
"request_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "TOO_MANY_REQUESTS",
"message": "Too Many Requests",
"request_id": "3fa85f64-5717-4562-b3fc-2c963f66afa6"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"request_id": "<string>"
}
}{
"error": {
"code": "UNAUTHORIZED",
"message": "<string>",
"request_id": "<string>"
}
}