Skip to main content
POST
/
gpus
/
v2
/
templates
Create Template
curl --request POST \
  --url https://api.novita.ai/gpus/v2/templates \
  --header 'Authorization: <authorization>' \
  --header 'Content-Type: <content-type>' \
  --data '
{
  "name": "pytorch-2.3-cuda12",
  "type": "instance",
  "image": "registry.example.com/ml/pytorch:2.3-cuda12",
  "registry_auth_id": "auth-001",
  "command": "",
  "entrypoint": "/bin/bash",
  "rootfs_size_gb": 50,
  "ports": [
    {
      "protocol": "http",
      "port": 8888
    }
  ],
  "envs": [
    {
      "key": "ENV",
      "value": "prod"
    }
  ],
  "metadata": {
    "readme": "PyTorch 2.3 with CUDA 12",
    "logo": "https://example.com/logo.png",
    "description": "PyTorch development template",
    "author": "PAI",
    "tags": [
      "pytorch",
      "cuda"
    ]
  },
  "min_cuda_version": "12.2"
}
'
import requests

url = "https://api.novita.ai/gpus/v2/templates"

payload = {
"name": "pytorch-2.3-cuda12",
"type": "instance",
"image": "registry.example.com/ml/pytorch:2.3-cuda12",
"registry_auth_id": "auth-001",
"command": "",
"entrypoint": "/bin/bash",
"rootfs_size_gb": 50,
"ports": [
{
"protocol": "http",
"port": 8888
}
],
"envs": [
{
"key": "ENV",
"value": "prod"
}
],
"metadata": {
"readme": "PyTorch 2.3 with CUDA 12",
"logo": "https://example.com/logo.png",
"description": "PyTorch development template",
"author": "PAI",
"tags": ["pytorch", "cuda"]
},
"min_cuda_version": "12.2"
}
headers = {
"Content-Type": "<content-type>",
"Authorization": "<authorization>"
}

response = requests.post(url, json=payload, headers=headers)

print(response.text)
const options = {
method: 'POST',
headers: {'Content-Type': '<content-type>', Authorization: '<authorization>'},
body: JSON.stringify({
name: 'pytorch-2.3-cuda12',
type: 'instance',
image: 'registry.example.com/ml/pytorch:2.3-cuda12',
registry_auth_id: 'auth-001',
command: '',
entrypoint: '/bin/bash',
rootfs_size_gb: 50,
ports: [{protocol: 'http', port: 8888}],
envs: [{key: 'ENV', value: 'prod'}],
metadata: {
readme: 'PyTorch 2.3 with CUDA 12',
logo: 'https://example.com/logo.png',
description: 'PyTorch development template',
author: 'PAI',
tags: ['pytorch', 'cuda']
},
min_cuda_version: '12.2'
})
};

fetch('https://api.novita.ai/gpus/v2/templates', 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://api.novita.ai/gpus/v2/templates",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
CURLOPT_POSTFIELDS => json_encode([
'name' => 'pytorch-2.3-cuda12',
'type' => 'instance',
'image' => 'registry.example.com/ml/pytorch:2.3-cuda12',
'registry_auth_id' => 'auth-001',
'command' => '',
'entrypoint' => '/bin/bash',
'rootfs_size_gb' => 50,
'ports' => [
[
'protocol' => 'http',
'port' => 8888
]
],
'envs' => [
[
'key' => 'ENV',
'value' => 'prod'
]
],
'metadata' => [
'readme' => 'PyTorch 2.3 with CUDA 12',
'logo' => 'https://example.com/logo.png',
'description' => 'PyTorch development template',
'author' => 'PAI',
'tags' => [
'pytorch',
'cuda'
]
],
'min_cuda_version' => '12.2'
]),
CURLOPT_HTTPHEADER => [
"Authorization: <authorization>",
"Content-Type: <content-type>"
],
]);

$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://api.novita.ai/gpus/v2/templates"

payload := strings.NewReader("{\n \"name\": \"pytorch-2.3-cuda12\",\n \"type\": \"instance\",\n \"image\": \"registry.example.com/ml/pytorch:2.3-cuda12\",\n \"registry_auth_id\": \"auth-001\",\n \"command\": \"\",\n \"entrypoint\": \"/bin/bash\",\n \"rootfs_size_gb\": 50,\n \"ports\": [\n {\n \"protocol\": \"http\",\n \"port\": 8888\n }\n ],\n \"envs\": [\n {\n \"key\": \"ENV\",\n \"value\": \"prod\"\n }\n ],\n \"metadata\": {\n \"readme\": \"PyTorch 2.3 with CUDA 12\",\n \"logo\": \"https://example.com/logo.png\",\n \"description\": \"PyTorch development template\",\n \"author\": \"PAI\",\n \"tags\": [\n \"pytorch\",\n \"cuda\"\n ]\n },\n \"min_cuda_version\": \"12.2\"\n}")

req, _ := http.NewRequest("POST", url, payload)

req.Header.Add("Content-Type", "<content-type>")
req.Header.Add("Authorization", "<authorization>")

res, _ := http.DefaultClient.Do(req)

defer res.Body.Close()
body, _ := io.ReadAll(res.Body)

fmt.Println(string(body))

}
HttpResponse<String> response = Unirest.post("https://api.novita.ai/gpus/v2/templates")
.header("Content-Type", "<content-type>")
.header("Authorization", "<authorization>")
.body("{\n \"name\": \"pytorch-2.3-cuda12\",\n \"type\": \"instance\",\n \"image\": \"registry.example.com/ml/pytorch:2.3-cuda12\",\n \"registry_auth_id\": \"auth-001\",\n \"command\": \"\",\n \"entrypoint\": \"/bin/bash\",\n \"rootfs_size_gb\": 50,\n \"ports\": [\n {\n \"protocol\": \"http\",\n \"port\": 8888\n }\n ],\n \"envs\": [\n {\n \"key\": \"ENV\",\n \"value\": \"prod\"\n }\n ],\n \"metadata\": {\n \"readme\": \"PyTorch 2.3 with CUDA 12\",\n \"logo\": \"https://example.com/logo.png\",\n \"description\": \"PyTorch development template\",\n \"author\": \"PAI\",\n \"tags\": [\n \"pytorch\",\n \"cuda\"\n ]\n },\n \"min_cuda_version\": \"12.2\"\n}")
.asString();
require 'uri'
require 'net/http'

url = URI("https://api.novita.ai/gpus/v2/templates")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true

request = Net::HTTP::Post.new(url)
request["Content-Type"] = '<content-type>'
request["Authorization"] = '<authorization>'
request.body = "{\n \"name\": \"pytorch-2.3-cuda12\",\n \"type\": \"instance\",\n \"image\": \"registry.example.com/ml/pytorch:2.3-cuda12\",\n \"registry_auth_id\": \"auth-001\",\n \"command\": \"\",\n \"entrypoint\": \"/bin/bash\",\n \"rootfs_size_gb\": 50,\n \"ports\": [\n {\n \"protocol\": \"http\",\n \"port\": 8888\n }\n ],\n \"envs\": [\n {\n \"key\": \"ENV\",\n \"value\": \"prod\"\n }\n ],\n \"metadata\": {\n \"readme\": \"PyTorch 2.3 with CUDA 12\",\n \"logo\": \"https://example.com/logo.png\",\n \"description\": \"PyTorch development template\",\n \"author\": \"PAI\",\n \"tags\": [\n \"pytorch\",\n \"cuda\"\n ]\n },\n \"min_cuda_version\": \"12.2\"\n}"

response = http.request(request)
puts response.read_body
{
  "template_id": "tpl-001"
}

Headers

Content-Type
string
required

Allowed value: application/json.

Authorization
string
required

Bearer authentication format, e.g.: Bearer {{API_KEY}}.

Body

application/json
name
string
required

Template name.

Example:

"pytorch-2.3-cuda12"

type
string
required

Template type.

Example:

"instance"

image
string
required

Image address.

Example:

"registry.example.com/ml/pytorch:2.3-cuda12"

registry_auth_id
string

Registry authentication ID.

Example:

"auth-001"

command
string

Startup command.

Example:

""

entrypoint
string

Image entrypoint.

Example:

"/bin/bash"

rootfs_size_gb
integer

Root disk size. Unit: GB.

Example:

50

ports
object[]

Exposed port configuration.

envs
object[]

Environment variables.

metadata
object

Template metadata.

min_cuda_version
string

Minimum CUDA version.

Example:

"12.2"

Response

200 - application/json

OK

template_id
string

Template ID

Example:

"tpl-001"

Last modified on June 23, 2026