SDKs
GraphQL Templates
Learn how to manage Templates using GraphQL.
Required Template Arguments
When creating templates, ensure you include the following required arguments:
containerDiskInGb
dockerArgs
env
imageName
name
volumeInGb
Note: Template names must be unique. Attempting to create a new template with an existing name will fail.
If your container image is private, you can include:
containerRegistryAuthId
: The ID (not the name) of the saved registry credentials in your user settings.
Creating Templates
Create GPU Template
curl --request POST \
--header 'content-type: application/json' \
--url 'https://api.tpu.one/graphql?api_key=${YOUR_API_KEY}' \
--data '{"query": "mutation { saveTemplate(input: { containerDiskInGb: 5, dockerArgs: \"sleep infinity\", env: [ { key: \"key1\", value: \"value1\" }, { key: \"key2\", value: \"value2\" } ], imageName: \"ubuntu:latest\", name: \"Generated Template\", ports: \"8888/http,22/tcp\", readme: \"## Hello, World!\", volumeInGb: 15, volumeMountPath: \"/workspace\" }) { containerDiskInGb dockerArgs env { key value } id imageName name ports readme volumeInGb volumeMountPath } }"}'
Create Serverless Template
Always pass
volumeInGb: 0
for Serverless templates.
curl --request POST \
--header 'content-type: application/json' \
--url 'https://api.tpu.one/graphql?api_key=${YOUR_API_KEY}' \
--data '{"query": "mutation { saveTemplate(input: { containerDiskInGb: 5, dockerArgs: \"python handler.py\", env: [ { key: \"key1\", value: \"value1\" }, { key: \"key2\", value: \"value2\" } ], imageName: \"tensorone/serverless-hello-world:latest\", isServerless: true, name: \"Generated Serverless Template\", readme: \"## Hello, World!\", volumeInGb: 0 }) { containerDiskInGb dockerArgs env { key value } id imageName isServerless name readme } }"}'
Modifying Templates
Modify GPU Pod Template
curl --request POST \
--header 'content-type: application/json' \
--url 'https://api.tpu.one/graphql?api_key=${YOUR_API_KEY}' \
--data '{"query": "mutation { saveTemplate(input: { id: \"wphkv67a0p\", containerDiskInGb: 5, dockerArgs: \"sleep infinity\", env: [ { key: \"key1\", value: \"value1\" }, { key: \"key2\", value: \"value2\" } ], imageName: \"ubuntu:latest\", name: \"Generated Template\", volumeInGb: 15, readme: \"## Goodbye, World!\" }) { id containerDiskInGb dockerArgs env { key value } imageName name volumeInGb readme } }"}'
Modify Serverless Template
curl --request POST \
--header 'content-type: application/json' \
--url 'https://api.tpu.one/graphql?api_key=${YOUR_API_KEY}' \
--data '{"query": "mutation { saveTemplate(input: { id: \"xkhgg72fuo\", containerDiskInGb: 5, dockerArgs: \"python handler.py\", env: [ { key: \"key1\", value: \"value1\" }, { key: \"key2\", value: \"value2\" } ], imageName: \"tensorone/serverless-hello-world:latest\", name: \"Generated Serverless Template\", volumeInGb: 0, readme: \"## Goodbye, World!\" }) { id containerDiskInGb dockerArgs env { key value } imageName name readme } }"}'
Deleting Templates
Note: Templates cannot be deleted if they are actively in use. After recent use by a Pod or Serverless Endpoint, allow up to 2 minutes before attempting deletion.
curl --request POST \
--header 'content-type: application/json' \
--url 'https://api.tpu.one/graphql?api_key=${YOUR_API_KEY}' \
--data '{"query": "mutation { deleteTemplate(templateName: \"Generated Template\") }"}'