v1

latestOpenAPI 3.1.02026-07-13897404.3 KB
Templates

create template

Creates a new template for launching instances.

Templates store default configuration values that can be used when creating instances. When an instance is created with a template reference, template values serve as defaults that can be overridden by request parameters.

For detailed usage, see Creating and Using Templates with API.

CLI Usage: vastai create template --name <name> --image <image> [options]

post/api/v0/template/

Request body

namestring required

Name of the template

imagestring required

Docker image path. Used when launching instances from this template.

tagstring

Docker image tag specifying version of the image. Defaults to latest. Can also be included in the image field instead.

envstring

Environment variables and port mappings in Docker flag format.

Example: "-e HF_TOKEN=hf_xxx123456789 -e MODEL_ID=TheBloke/Llama-2-7B-Chat-GPTQ -p 8000:8000"

onstartstring

Commands to run when instance starts

Example : env | grep _ >> /etc/environment; echo 'starting up'

runtype'ssh' | 'jupyter' | 'args'

Launch mode for the instance. Defaults to args. Recommended - use ssh with ssh_direct: true for reliable SSH access.

ssh_directboolean

Enable direct SSH connection

jup_directboolean

Enable direct Jupyter connection

jupyter_dirstring

Directory to launch Jupyter from

Example : /home/notebooks

use_jupyter_labboolean

Use JupyterLab instead of Jupyter Notebook

docker_login_repostring

Name of the private Docker repo (i.e docker.io)

docker_login_userstring

Username for private Docker repo

docker_login_passstring

Access token or password for private Docker repo.

extra_filtersobject

Additional machine search filters. Example: {"cuda_max_good": {"gte": 12.6}}

recommended_disk_spacenumber

Recommended disk space in GB. Defaults to 8GB if not specified.

descstring

Short description of the template

readmestring

Longer documentation/readme content for the template

args_strstring

Arguments string passed to the container entrypoint when runtype is args

use_sshboolean

Enable SSH access to instances created from this template

hrefstring

Link to Docker Hub or image documentation

repostring

Repository identifier (e.g., library/ubuntu)

privateboolean

Whether the template is private (not publicly searchable)

volume_infoobject nullable

UI hint for volume configuration. Note: This does not affect instance creation - use volume_info in the instance creation request to actually attach volumes.

hash_idstring

Content-based hash ID of the template. Can be included when editing but will change based on new content.

Response

Template created or existing template found

successboolean

Whether operation was successful

msgstring

Status message

Example response

{
  "msg": "Template Created Successfully! New Template ID: 123456"
}