Skip to main content
A template is a configuration bundle that stores default settings for instance creation. Instead of passing every parameter each time you create an instance, you define a template once and reference it by its hash_id. You can optionally override specific values at creation time. Templates are useful for:
  • Standardization — ensure all team members launch instances with consistent configurations
  • Convenience — avoid repeating the same image, env, and onstart parameters across commands
  • Sharing — distribute configurations via template hash ID
For information about managing templates in the web interface, see Templates Introduction.

Template Fields Reference

When creating or editing a template, the following fields can be configured:

Template Identifiers

Templates have two identifiers. Which one you use depends on the operation:
The hash_id is derived from the template’s content. After editing a template, the hash_id changes. Always retrieve the latest hash_id from the command output or by searching for the template.

Create a Template

Use vastai create template to define a reusable configuration:
The output includes both identifiers:
Save both the id and hash_id — you’ll need them for different operations. You can also attach default machine search filters using --search_params:

Search for Templates

Find templates using vastai search templates with the same query syntax used by search offers:

Query Syntax

Quote the query string to prevent shell interpretation of > and < characters.

Searchable Fields

Create an Instance from a Template

Pass --template_hash to create instance to use a template as the base configuration. You don’t need to specify --image or other fields already defined in the template:
Output:
You can combine a template with an interruptible (spot) bid:

Override Template Values

When you create an instance with both a template and additional flags, the following precedence rules apply:

Example: Overriding the Image

Example: Merging Environment Variables

If your template defines:
And you create an instance with:
The resulting environment will be:
  • MODEL_ID=mistralai/Mistral-7B-v0.1 — request overrides template
  • MAX_TOKENS=4096 — retained from template
  • HF_TOKEN=hf_xxx — added from request

Edit a Template

Update an existing template using vastai update template with the template’s hash_id as the positional argument. Editing creates a new version of the template. Values from the previous version are not carried over, so pass the full set of flags the new version should have. The flags are the same ones create template accepts:
An omitted flag takes its default on the new version, not the previous version’s value. To change one setting, repeat every other flag with its current value. Without --public the new version is private, without --hide-readme the readme is visible, without --ssh or --jupyter the runtype is args, without --search_params the default machine filters are used, and without --disk_space the recommended disk space is 16 GB.Fields that have no flag are not sent at all and are empty on the new version: registry username and password (--login sets only the registry), volume_info, args_str and the readme. If the template uses any of these, re-enter them in the console after a CLI edit.
The new version gets a new id and hash_id because the hash is derived from the template’s content. Use the new hash_id returned in the output for subsequent operations. The previous version keeps its identifiers, so running instances and shared links stay valid. A command whose values match the current version exactly creates nothing and returns the existing hash_id.

Delete a Template

Delete a template using either its numeric id or its hash_id:
Deleting a template removes your relationship to it. It does not destroy the underlying template record.

Common Pitfalls

Templates have two identifiers and each is used in different contexts:
  • create instance --template_hash takes the hash_id (string)
  • update template takes the hash_id as a positional argument
  • delete template --template-id takes the numeric id (integer)
If you pass the numeric id where a hash_id is expected (or vice versa), the operation will fail.
The --env flag expects Docker flag format as a single string, not key=value pairs:
Port mappings are also specified in this string using -p:
When you specify both --template_hash and --image, the --image flag overrides the template’s image. If you want to use the template’s image, omit the --image flag entirely.
The volume_info field stored in templates is a UI hint only. To actually mount a volume, pass the volume flags in the create instance command:
This is expected behavior. The hash_id is content-based, so any edit that changes a value produces a new version with a new hash. Always capture the hash_id from the update command output or search for your template again before referencing it.