curl --request PUT \
--url https://console.vast.ai/api/v0/instances/update_template/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"template_id": 99,
"template_hash_id": "abc123def456",
"image": "pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime",
"onstart": "pip install mypackage",
"image_login": "-u myuser -p mypass docker.io",
"disk": 20,
"recycle": true
}
'import requests
url = "https://console.vast.ai/api/v0/instances/update_template/{id}"
payload = {
"template_id": 99,
"template_hash_id": "abc123def456",
"image": "pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime",
"onstart": "pip install mypackage",
"image_login": "-u myuser -p mypass docker.io",
"disk": 20,
"recycle": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
template_id: 99,
template_hash_id: 'abc123def456',
image: 'pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime',
onstart: 'pip install mypackage',
image_login: '-u myuser -p mypass docker.io',
disk: 20,
recycle: true
})
};
fetch('https://console.vast.ai/api/v0/instances/update_template/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://console.vast.ai/api/v0/instances/update_template/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'template_id' => 99,
'template_hash_id' => 'abc123def456',
'image' => 'pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime',
'onstart' => 'pip install mypackage',
'image_login' => '-u myuser -p mypass docker.io',
'disk' => 20,
'recycle' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://console.vast.ai/api/v0/instances/update_template/{id}"
payload := strings.NewReader("{\n \"template_id\": 99,\n \"template_hash_id\": \"abc123def456\",\n \"image\": \"pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime\",\n \"onstart\": \"pip install mypackage\",\n \"image_login\": \"-u myuser -p mypass docker.io\",\n \"disk\": 20,\n \"recycle\": true\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://console.vast.ai/api/v0/instances/update_template/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"template_id\": 99,\n \"template_hash_id\": \"abc123def456\",\n \"image\": \"pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime\",\n \"onstart\": \"pip install mypackage\",\n \"image_login\": \"-u myuser -p mypass docker.io\",\n \"disk\": 20,\n \"recycle\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.vast.ai/api/v0/instances/update_template/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"template_id\": 99,\n \"template_hash_id\": \"abc123def456\",\n \"image\": \"pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime\",\n \"onstart\": \"pip install mypackage\",\n \"image_login\": \"-u myuser -p mypass docker.io\",\n \"disk\": 20,\n \"recycle\": true\n}"
response = http.request(request)
puts response.read_body{
"success": true
}{
"error": "<string>",
"msg": "<string>"
}{
"error": "<string>",
"msg": "<string>"
}Update Instance Template
Updates the image, environment, or template associated with an existing instance, optionally recycling it immediately.
curl --request PUT \
--url https://console.vast.ai/api/v0/instances/update_template/{id} \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '
{
"template_id": 99,
"template_hash_id": "abc123def456",
"image": "pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime",
"onstart": "pip install mypackage",
"image_login": "-u myuser -p mypass docker.io",
"disk": 20,
"recycle": true
}
'import requests
url = "https://console.vast.ai/api/v0/instances/update_template/{id}"
payload = {
"template_id": 99,
"template_hash_id": "abc123def456",
"image": "pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime",
"onstart": "pip install mypackage",
"image_login": "-u myuser -p mypass docker.io",
"disk": 20,
"recycle": True
}
headers = {
"Authorization": "Bearer <token>",
"Content-Type": "application/json"
}
response = requests.put(url, json=payload, headers=headers)
print(response.text)const options = {
method: 'PUT',
headers: {Authorization: 'Bearer <token>', 'Content-Type': 'application/json'},
body: JSON.stringify({
template_id: 99,
template_hash_id: 'abc123def456',
image: 'pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime',
onstart: 'pip install mypackage',
image_login: '-u myuser -p mypass docker.io',
disk: 20,
recycle: true
})
};
fetch('https://console.vast.ai/api/v0/instances/update_template/{id}', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://console.vast.ai/api/v0/instances/update_template/{id}",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "PUT",
CURLOPT_POSTFIELDS => json_encode([
'template_id' => 99,
'template_hash_id' => 'abc123def456',
'image' => 'pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime',
'onstart' => 'pip install mypackage',
'image_login' => '-u myuser -p mypass docker.io',
'disk' => 20,
'recycle' => true
]),
CURLOPT_HTTPHEADER => [
"Authorization: Bearer <token>",
"Content-Type: application/json"
],
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"strings"
"net/http"
"io"
)
func main() {
url := "https://console.vast.ai/api/v0/instances/update_template/{id}"
payload := strings.NewReader("{\n \"template_id\": 99,\n \"template_hash_id\": \"abc123def456\",\n \"image\": \"pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime\",\n \"onstart\": \"pip install mypackage\",\n \"image_login\": \"-u myuser -p mypass docker.io\",\n \"disk\": 20,\n \"recycle\": true\n}")
req, _ := http.NewRequest("PUT", url, payload)
req.Header.Add("Authorization", "Bearer <token>")
req.Header.Add("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.put("https://console.vast.ai/api/v0/instances/update_template/{id}")
.header("Authorization", "Bearer <token>")
.header("Content-Type", "application/json")
.body("{\n \"template_id\": 99,\n \"template_hash_id\": \"abc123def456\",\n \"image\": \"pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime\",\n \"onstart\": \"pip install mypackage\",\n \"image_login\": \"-u myuser -p mypass docker.io\",\n \"disk\": 20,\n \"recycle\": true\n}")
.asString();require 'uri'
require 'net/http'
url = URI("https://console.vast.ai/api/v0/instances/update_template/{id}")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Put.new(url)
request["Authorization"] = 'Bearer <token>'
request["Content-Type"] = 'application/json'
request.body = "{\n \"template_id\": 99,\n \"template_hash_id\": \"abc123def456\",\n \"image\": \"pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime\",\n \"onstart\": \"pip install mypackage\",\n \"image_login\": \"-u myuser -p mypass docker.io\",\n \"disk\": 20,\n \"recycle\": true\n}"
response = http.request(request)
puts response.read_body{
"success": true
}{
"error": "<string>",
"msg": "<string>"
}{
"error": "<string>",
"msg": "<string>"
}Authorizations
API key must be provided in the Authorization header
Path Parameters
Instance contract ID whose template to update.
Body
Numeric ID of an existing template to apply to the instance.
99
Hash ID of an existing template to apply; takes precedence over template_id.
"abc123def456"
Docker image reference to set on the instance.
"pytorch/pytorch:2.0.0-cuda11.7-cudnn8-runtime"
Shell script to run when the instance starts.
"pip install mypackage"
Docker registry login credentials used to pull a private image, in the format '-u -p '.
"-u myuser -p mypass docker.io"
Disk allocation in GB; minimum 8 GB.
20
If true, immediately recycle the instance after applying the template update.
true
Response
Returns {success: true} on successful update, or the recycle response {success: true/false} if recycle was requested.
True when update succeeded