POST
/
gpu-instance
/
openapi
/
v1
/
template
/
create

Request Headers

Content-Type
string
required

Enum: application/json

Authorization
string
required

Bearer authentication format, for example: Bearer {{API Key}}.

Request Body

template
object
required

Template settings.

name
string
required

Template name.

readme
string
required

Template README content (in Markdown format).

type
string
required

Template type.
Enum: instance

channel
string
required

Template channel.
Enum: private

image
string
required

Docker image address for instance startup.

startCommand
string
required

Startup command for the instance.

rootfsSize
integer
required

Root filesystem storage (GB).

localVolumeSize
integer
required

Local volume storage (GB).

localVolumeMount
string
required

Local volume mount path.

ports
object[]
required

Exposed port settings.

type
string
required

Exposed port types.
Enum: http, tcp

ports
string[]
required

Exposed ports (maximum of 10).

volumes
object[]
required

Volume settings.

type
string

Volume type.

size
integer

Volume size (GB).

mountPath
string

Volume mount path.

envs
object[]
required

Environment variables injected into the instance.

key
string

Environment variable key.

value
string

Environment variable value.

Response

templateId
string

ID of the created template.

Example

Request


curl --request POST \
  --url 'https://api.novita.ai/gpu-instance/openapi/v1/template/create' \
  --header 'Authorization: Bearer {{API Key}}' \
  --header 'Content-Type: application/json' \
  --data '{
    "template": {
      "name": "test",
      "readme": "readme",
      "type": "instance",
      "channel": "private",
      "image": "redis",
      "startCommand": "",
      "rootfsSize": 10,
      "localVolumeSize": 20,
      "localVolumeMount": "/workspace",
      "ports": [
        {
          "type": "tcp",
          "ports": [
            "8080",
            "8090"
          ]
        },
        {
          "type": "http",
          "ports": [
            "6000",
            "60001"
          ]
        }
      ],
      "volumes": [
        {
          "type": "local",
          "size": 20,
          "mountPath": "/workspace"
        }
      ],
      "envs": [
        {
          "key": "testkey",
          "value": "123"
        }
      ]
    }
  }'

Response

{
  "templateId": "1"
}