Templates in Shadeform allow you to save and reuse instance configurations, making it easy to launch instances with predefined settings like launch configurations, networking rules, and environment variables. Templates are particularly useful when you need to repeatedly deploy instances with the same configuration or share configurations with team members.

In this guide, we’ll cover how to create, use, and manage templates via the Shadeform API.

Prerequisites

There are two pre-requisites for this guide:

  1. After you have created your account, you must top up your wallet here.
  2. After you have topped up your wallet, generate and retrieve your Shadeform API key here.

Step 1: Create a Template

To create a new template, use the /templates/save endpoint. You can define various configurations including launch settings, networking rules, and environment variables.

Example Response

Response
{
  "id": "d290f1ee-6c54-4b01-90e6-d701748f0851"
}

Step 2: View Template Details

After creating a template, you can view its details using the /templates/{template_id}/info endpoint. Use the id from the response in Step 1. If you want to see templates you have created, use the /templates endpoint.

Example Response

Response
{
  "id": "template-123",
  "name": "vLLM Deployment",
  "description": "Template for vLLM",
  "public": false,
  "launch_configuration": {
    "type": "docker",
    "docker_configuration": {
      "image": "vllm/vllm-openai:latest",
      "args": "--model mistralai/Mistral-7B-v0.1",
      "envs": [
        {
          "name": "HUGGING_FACE_HUB_TOKEN",
          "value": "hugging_face_api_token"
        }
      ],
      "port_mappings": [
        {
          "container_port": 8000,
          "host_port": 8000
        }
      ]
    }
  },
  "tags": ["vllm", "development"]
}

Step 3: Launch an Instance Using a Template

To use a template when creating an instance, include the template_id in your instance creation request using the /instances/create endpoint.

Example Response

Response
{
  "id": "cc9f6b74-9825-4854-9e9c-dd50c7e97c3a",
  "cloud_assigned_id": "720f2a6a-e4ee-488a-ade1-e7892f5d730a"
}

Step 4: Delete a Template

When you no longer need a template, you can delete it using the /templates/{template_id}/delete endpoint.

Summary

Templates provide a powerful way to standardize and automate your instance deployments.

For more details about template configurations and available options, check out the Templates API reference.