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 calls
- Sharing — distribute configurations via template hash ID
Setup
Template Fields Reference
When creating or editing a template, the following fields can be configured:| Field | Type | SDK Parameter | Description |
|---|---|---|---|
name | string | name | Human-readable name for the template |
image | string | image | Docker image path (e.g., vllm/vllm-openai) |
tag | string | image_tag | Docker image tag. Defaults to latest |
desc | string | desc | Short description of the template |
readme | string | readme | Longer documentation/readme content |
env | string | env | Environment variables and port mappings in Docker flag format (e.g., "-e VAR=val -p 8000:8000") |
onstart | string | onstart_cmd | Shell commands to run when the instance starts |
runtype | string | ssh / jupyter | Launch mode: ssh, jupyter, or args (default). Set via boolean flags |
ssh_direct | boolean | ssh=True, direct=True | Enable direct SSH (set by combining ssh and direct) |
use_ssh | boolean | ssh | Enable SSH access |
jup_direct | boolean | jupyter=True, direct=True | Enable direct Jupyter (set by combining jupyter and direct) |
jupyter_dir | string | jupyter_dir | Directory to launch Jupyter from |
use_jupyter_lab | boolean | jupyter_lab | Use JupyterLab instead of Jupyter Notebook |
docker_login_repo | string | login | Private Docker registry URL (first token of the login string) |
extra_filters | object | search_params | Default machine search filters (parsed from query string) |
recommended_disk_space | number | disk_space | Recommended disk space in GB |
private | boolean | (private by default) | Templates are private by default |
href | string | href | Link to Docker Hub or image documentation |
repo | string | repo | Repository identifier |
Template Identifiers
Templates have two identifiers. Which one you use depends on the operation:| Identifier | Type | Used For |
|---|---|---|
id | integer | Deleting templates (template_id parameter) |
hash_id | string | Creating instances (template_hash parameter), editing templates (HASH_ID parameter) |
Create a Template
Usecreate_template() to define a reusable configuration:
id and hash_id — you’ll need them for different operations.
You can also attach default machine search filters using search_params:
Method Signature
Search for Templates
Usesearch_templates() with the same query syntax used by search_offers():
Query Syntax
Searchable Fields
| Field | Type | Description |
|---|---|---|
creator_id | int | ID of the creator |
created_at | float | Time of initial creation (UTC epoch) |
count_created | int | Number of instances created (popularity) |
default_tag | string | Image default tag |
docker_login_repo | string | Image docker repository |
id | int | Template unique ID |
image | string | Image used for the template |
jup_direct | bool | Supports Jupyter direct |
hash_id | string | Unique hash ID |
name | string | Displayable name |
recent_create_date | float | Last time of instance creation (UTC epoch) |
recommended_disk_space | float | Minimum disk space required |
recommended | bool | On the recommended list |
ssh_direct | bool | Supports SSH direct |
tag | string | Image tag |
use_ssh | bool | Supports SSH (direct or proxy) |
Method Signature
Create an Instance from a Template
Passtemplate_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:
Override Template Values
When you create an instance with both a template and additional parameters, the following precedence rules apply:| Field Type | Behavior |
|---|---|
| Scalar fields (image, disk, runtype, etc.) | Request value overrides template value |
env (string) | Merged. Template values retained, request values appended. Conflicting keys use the request value |
extra_filters (dict) | Merged by key. Request values win on conflicts |
Example: Overriding the Image
Example: Merging Environment Variables
If your template defines:MODEL_ID=mistralai/Mistral-7B-v0.1— request overrides templateMAX_TOKENS=4096— retained from templateHF_TOKEN=hf_xxx— added from request
Edit a Template
Update an existing template usingupdate_template() with the template’s hash_id as the HASH_ID parameter. Include only the parameters you want to change:
create_template():
The
hash_id changes after editing because it is derived from the template’s content. Use the new hash_id returned in the result for subsequent operations.Method Signature
Delete a Template
Delete a template using either its numericid or its hash_id:
Deleting a template removes your relationship to it. It does not destroy the underlying template record.
Method Signature
Common Pitfalls
Using the wrong identifier for the operation
Using the wrong identifier for the operation
Templates have two identifiers and each is used in different contexts:
create_instance(template_hash=...)takes the hash_id (string)update_template(HASH_ID=...)takes the hash_id (string)delete_template(template_id=...)takes the numeric id (integer)
id where a hash_id is expected (or vice versa), the operation will fail. You can also call delete_template(hash_id=...) with the hash if you don’t have the numeric ID.Environment variables aren't applying
Environment variables aren't applying
The Port mappings are also specified in this string using
env parameter expects Docker flag format as a single string, not key=value pairs or a dictionary:-p:Template image overridden unexpectedly
Template image overridden unexpectedly
When you specify both
template_hash and image in create_instance(), the image parameter overrides the template’s image. If you want to use the template’s image, omit the image parameter entirely.Volume didn't mount from template
Volume didn't mount from template
The See the API templates page for the JSON
volume_info field stored in templates is a UI hint only. To actually mount a volume, you must pass volume information in the instance creation request. Use the API directly or the CLI volume flags for this:volume_info structure.hash_id changed after editing
hash_id changed after editing
This is expected behavior. The
hash_id is content-based, so any edit produces a new hash. Always capture the new hash_id from the update_template() return value or search for your template again before referencing it.