# Templates

A template is the software that starts on your server. You choose one in the second step of **Deploy**. Browse them first in **Templates**.

## Find a template by goal

The filters group templates by what you want to do:

- **Chat with an AI model:** talk to an open AI model in your browser.
- **Generate images:** create and edit images in a visual workspace.
- **Speech:** turn speech into text, or text into speech.
- **Train and fine-tune:** teach a model with your own data.
- **Notebooks and coding:** notebooks, code editors and plain GPU machines for your own code, for example CUDA or PyTorch.
- **Serve an API:** give your apps a web address that answers with an AI model.
- **Data and vector databases:** databases and labeling tools for AI data.
- **Agents and automation:** connect AI models and apps in automations.

In **Templates** and in **Deploy** there is also **My templates**, for templates made by your own organization. A filter only shows when at least one template is in it.

Search by name or image, and open a template to see its details: container image, launch mode, ports, environment variable names, minimum VRAM and default disk size. Secret values are never shown.

## Compare templates

On the **Templates** page of our website, **What do you want to do?** narrows the list to one goal, cheapest first, and the search finds a template even when you mistype its name. Templates marked **Beginner friendly** open in your browser with a sign-in made for you, so there is nothing to set up.

Select **Compare** on two or three templates, then open the comparison. It shows side by side the GPU memory each one needs, the price per hour of the cheapest server that fits, how long the first start takes, how you use it (a web page, an API, a notebook or a terminal), whether it suits beginners and what you get. Prices are live and change with supply.

Not sure how much GPU memory you need? See [Which GPU do I need?](/docs/tutorial-which-gpu).

## Launch modes

- **SSH:** you connect with a terminal. See [Connect with SSH](/docs/connect-ssh).
- **Jupyter:** you open a notebook in the browser. See [Connect with Jupyter](/docs/connect-jupyter).
- **Container (entrypoint):** the image's own command runs, with the arguments you set. If the template names an app port, you open it from the server page. See [Expose an app](/docs/expose-an-app).

## Minimum VRAM

A template can set a minimum amount of GPU memory. A GPU with less is marked and cannot be selected with it.

## Environment variables

Some templates come with variables, for example a model name. You can change them on the configure step. See [Environment variables](/docs/environment-variables).

## Make your own template

Owners and admins can make templates in **Templates → New template**. Everyone in the organization can deploy them.

1. Enter a name, a short description and, if you like, a README (plain text shown in the details).
2. Enter a container image and a tag. You can paste a full reference such as `ghcr.io/team/app:1.2`; it is split into image and tag. A `sha256:` digest also works as the tag.
3. Choose a launch mode: SSH, Jupyter notebook, or Container (entrypoint). For a container you can add arguments that are passed to the image's own command. Arguments are one line and are not run through a shell.
4. Add the ports your software uses, TCP or UDP, between 1 and 65535, up to 16. A Jupyter template needs an app port from that list; for a container it is optional.
5. Add environment variables. Mark a variable as secret to mask it. Secret values are stored encrypted and are never shown again; when you edit the template, leave a secret blank to keep it.
6. Optionally add a start script (up to 8,000 characters). It runs each time the server starts, after our own setup, and is stored as text, not built into a command. Our own setup shares a launch field of 4,048 characters with your script, so about 2,300 characters of script fit (about 1,300 with the browser terminal). A longer one is refused with **The start script is too long**; keep long logic in a file and start it from a short script.
7. Set the default disk size and the minimum GPU memory, then select **Save template**.

Use **Duplicate** in the template details to copy one of your templates, including its secrets and registry login. Select **Deploy with this** to use a template. Deleting a template does not affect servers that already use it.

### Save a server as a template

Owners and admins can turn a server's launch settings into a new template: open the server, go to **Settings** and select **Save as template**, then enter a name (it must differ from the names of your other templates). The template gets the server's image and tag, launch mode, start script, ports, disk size (as the default disk), hardware needs and environment variables. The server is not touched. Servers of a serverless endpoint or a server group cannot be saved this way.

Secret values are never copied. Plain values are copied as they are. Every secret, whether it came from the template or was added at launch, and every plain variable whose name looks like a key, token or password, is saved by name with an empty value: fill it in by editing the template, or add a secret with the same name when you launch. A value that points at your secrets store (`secret:NAME`) is kept as that reference, so the new template keeps reading the stored secret. Variables the platform sets for each server, such as the browser-terminal password and the self-stop key, are left out.

Values are copied only when you launched the server yourself or your role may manage every server (`servers.manage`). Otherwise the template is still created, but every variable is saved by name with an empty value, and the start script is the source template's own, not the one set at launch.

Through the API: `POST /api/v1/servers/{id}/template` with an optional `name` and `summary`; the answer lists `secretsToFill` and `secretRefs`. In the CLI: `apidly templates save SERVER_ID --name "My setup"`.

Step by step: [Turn a working server into your own template](/docs/tutorial-server-to-template).

### Share, export and import

A template can be shared through a link (**Share** on the template), exported as a file, and imported from a file or a shared link. Through the API: `GET`, `POST` and `DELETE /api/v1/templates/{id}/share`, `GET /api/v1/templates/{id}/export`, `POST /api/v1/templates/import`, `POST /api/v1/template-shares/{token}/import`, and `POST /api/v1/template-shares/{token}/report` to report a shared template. In the CLI: `apidly templates share`, `shares`, `unshare`, `export`, `import` and `report`.

## Private registries

For an image in a private registry, open **Templates → Registries** and add a login: the registry host (for example `ghcr.io`), a username and an access token with read access. Owners and admins manage logins; everyone can see the host, the username and the last four characters of the token. The token is stored encrypted and is never shown again. To replace it, use **Update**. A login cannot be removed while a template uses it.

In the template form, choose the login under **Private registry login**. It is used only to pull the image when a server starts. Tokens are also removed from server logs we show you.

## Change a template for one launch

On the configure step of **Deploy**, open **Advanced** to edit variables, ports and, for your own templates, the start script for this server only. The template is not changed. Select **Save as template** there to keep your changes as a new template.

## Software that is not included

The image contains only what the template describes. You may install more on your server. You are responsible for what you install, including its license terms.

<!-- task-guide-0134 -->

## Check a registry login before you launch

`POST /api/v1/registries/{id}/check` tries a saved login against the registry's own sign-in. Nothing is pulled, launched or charged. `result` is `accepted`, `refused` (the registry said no to this username and token: replace them with **Update** or `PATCH /api/v1/registries/{id}`), or `unchecked` with a `reason` such as `auth_elsewhere`, `open` or `unreachable` when the registry gave no clear answer. You need a key with the `full` scope whose creator may manage templates; an organization can run 10 checks a minute.

```bash
curl -X POST "https://apidly.com/api/v1/registries/REGISTRY_ID/check" \
  -H "Authorization: Bearer $APIDLY_API_KEY"
# {"check": {"host": "ghcr.io", "result": "accepted", "reason": null}}

apidly registries
apidly registries check REGISTRY_ID
```

```js
import { Apidly } from "@apidly/sdk";

const apidly = new Apidly({ apiKey: process.env.APIDLY_API_KEY });
const { check } = await apidly.registries.check("REGISTRY_ID");
if (check.result === "refused") {
  console.error(`${check.host} refused the saved login`);
}
```

```python
import os
from apidly import Client

client = Client(api_key=os.environ["APIDLY_API_KEY"])
check = client.registries.check("REGISTRY_ID")["check"]
print(check["result"], check["reason"])
```

Launches can also check the login first, so a refused token stops the request with `400 registry_login_refused` before anything is launched or charged. This check before each launch may not be switched on for your account; without it, a refused token shows as a server that cannot download its image (see [If a server fails to start](/docs/if-a-server-fails-to-start)).
