Skip to main content
Apidly Cloud
Cookie policy

Analytics and ad cookies stay off unless you accept. Cookie policy

We would like to use Google Analytics and Microsoft Clarity to understand how the public pages are used, including page views and session recordings, and the Reddit Pixel to measure whether our ads on Reddit lead to visits and sign-ups. You choose here whether they are on. Rejecting changes nothing about how the site works.

Launch file

Save a server's launch settings as a JSON file, edit it, keep it in a repository and launch the same server again with apidly deploy -f or the API.

Last updated November 24, 20265 min read
View as Markdown

A launch file is a server's launch settings in one JSON file: the exact request that POST /api/v1/servers accepts. Keep it next to your code, edit it like any other file and launch the same server again whenever you need it, from your computer or from a CI job. Writing the file creates, changes and charges nothing.

Get the file

  • Console: open the server, go to Settings and select Download launch file. If some variables are not in the file, the message lists them.
  • CLI: apidly servers export ins_ID -f server.json writes the file and prints what is not in it. Without -f (or with -f -) the file is printed and the notes go to standard error, so apidly servers export ins_ID > server.json works too.
  • API: GET /api/v1/servers/{id}/launch-file. The answer has the file in launchFile, plus secretsToFill, secretRefs, notCopied, valuesCopied and sourceServerId. 30 calls a minute per key.

Anyone who can see the server can export it. Servers that a serverless endpoint or a server group started answer 409 invalid_state: change the endpoint or the group instead. A member whose role covers only their own servers gets 404 for another member's server.

What the file contains

{
  "planId": "pln_example",
  "templateId": "tpl_example",
  "label": "fine-tune",
  "diskGb": 100,
  "sshKeyIds": ["ssh_example"],
  "env": { "MODEL_NAME": "my-model", "HF_TOKEN": "secret:HF_TOKEN" },
  "pricing": "on_demand",
  "fallbackPlanIds": [],
  "allowSelfStop": false,
  "webTerminal": false,
  "tags": ["research"],
  "automation": { "maxRuntimeHours": 8 }
}
  • planId, templateId, label, diskGb and sshKeyIds, as the server was launched.
  • env: the plain environment variables. A value that points at your secrets store (secret:NAME) stays that reference, so the file never holds the secret itself (listed in secretRefs).
  • pricing (on_demand or interruptible), fallbackPlanIds, allowSelfStop (the self-stop key), webTerminal (the browser terminal, only while the platform offers it) and tags.
  • constraints: the hardware needs (region, hosting, minimum CPU, RAM, bandwidth, CUDA), when the launch had any.
  • automation: the repeating automation rules: longest run time, idle stop, spending cap and weekly schedule.

What is deliberately left out

  • Secret values. Launch secrets, and plain variables whose name looks like a key, token or password, are never written. Their names are in secretsToFill and in the message when you download the file. Send them again when you launch.
  • Values of another member's server. Values are copied only when you launched the server yourself or your role may manage every server. Otherwise the file has no values at all, every variable name is in secretsToFill and valuesCopied is false.
  • Variables the platform sets for each server, such as the browser-terminal password and the self-stop key. A new server gets its own.
  • Listed in notCopied when they applied: an attached volume (volume: a volume belongs to one server at a time), a planned one-off stop or destroy time (one_off_times: a moment, not a setting), port overrides (port_overrides) and a start-command override (start_command).
  • The files on the disk. A launch file keeps settings, not data. Keep data on a volume or copy it off (see Fine-tune or train: keep your work safe).

Launch from the file

apidly deploy -f server.json --env HF_TOKEN=hf_example --dry-run
apidly deploy -f server.json --env HF_TOKEN=hf_example --wait

The first command checks the request and shows the hourly price without creating anything. The second launches after asking Deploy? [y/N]. Every option you give on the command line wins over the file: --label, --plan, --disk, --tag, --interruptible or --on-demand, and the others. Variables are merged: the file's env first, then --env-file, then each --env. -f - reads the file from standard input, and the whole answer of GET .../launch-file is accepted as well.

Through the API, send the file as the body of POST /api/v1/servers. Add the secrets to env before you send it:

curl -X POST https://apidly.com/api/v1/servers \
  -H "Authorization: Bearer $APIDLY_API_KEY" \
  -H "Content-Type: application/json" \
  -H "Idempotency-Key: $(uuidgen)" \
  --data @server.json

A launch from a file is a new request like any other: today's price, your balance, stock and, for a new account, our review apply. If the plan is out of stock, pass another one with --plan or add plans to fallbackPlanIds.

Edit the file

The file is plain JSON, so change it by hand: a bigger diskGb, another label, more tags, a lower automation.maxRuntimeHours. A few rules:

  • planId and templateId are required. apidly plans and apidly templates list the ones you can use; slugs work on the command line (--plan), ids in the file.
  • sshKeyIds and a template of your own belong to your organization: in another organization, change them.
  • Leave out what you do not need. Without sshKeyIds the organization's default SSH keys are installed; without automation the default automatic stop applies.
  • Never write a secret value into the file. Store it in Secrets and put secret:NAME as the value (see Secrets), or pass it with --env at launch.

Use it in CI

Commit the file (it holds no secret values) and launch from a job with an API key kept in the CI system's own secret store. Without a terminal the CLI does not ask, so pass --yes:

export APIDLY_API_KEY="$CI_APIDLY_KEY"
apidly deploy -f server.json --env HF_TOKEN="$HF_TOKEN" --label "ci-$CI_JOB_ID" --yes --wait --json

Use a key with the Servers scope. Put a longest run time in the file's automation, so a job that fails half-way does not leave a server running, and destroy the server at the end of the job with apidly destroy ins_ID --yes.

Give the CI key a monthly spending limit as well: launches with it are refused once it is reached (see API keys).

Next

Ready to try it?

Create a free account and add credit when you want to start a server. The smallest top-up is $10.

Create a free account

Was this helpful?

Still stuck? Contact us