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.

Use the CLI and API from scratch

Install the apidly command, create an API key, then deploy, connect to, stop and delete a server from your terminal or a script.

Last updated November 24, 20265 min read
View as Markdown

Everything you did in the console can be done from a terminal or a script. In this tutorial you install the apidly command, sign in with an API key, run a server and clean it up. You need Node 18 or newer, credit, and an SSH key added under SSH keys.

1. Install the command

The page Command-line tool lists the install commands with a checksum check. Follow them, or use this short form:

curl -fsSLo apidly-cli.tgz https://apidly.com/downloads/apidly-cli.tgz
npm install -g ./apidly-cli.tgz
apidly --version

The last command prints the version number.

2. Create an API key and sign in

  1. Open API keys and select Create key.
  2. Name it laptop. Under Permissions, choose Servers: the command can then request, start, stop and delete servers, but not add credit. Choose Full access only if it should also add credit or manage SSH keys and templates. Optionally set an expiry.
  3. Copy the key. It is shown only once.
apidly init

init asks for the key, with the text hidden, checks it and saves it in ~/.config/apidly/config.json. It then offers to upload your SSH public key when your organization has none, and shows your organization and balance. To only save a key, run apidly login instead; apidly whoami shows your organization, balance and runway. In scripts and CI, set the APIDLY_API_KEY environment variable instead of signing in. See API keys.

Something not working? Run apidly doctor. It checks the version, your saved key, the connection to the API, your balance and your SSH keys, and says how to fix what is wrong. apidly doctor --offline skips the checks that need the network. Every check is explained in Check your setup with apidly doctor.

3. Find a plan and a template

apidly plans --available --min-vram 8 --sort price --limit 5
apidly templates
apidly ssh-keys

The first command lists the five cheapest plans that can be requested now, with the price per hour. Copy a plan SLUG. The second lists template slugs, for example pytorch. The third lists your SSH keys; copy the id of yours.

4. Deploy

apidly deploy --plan PLAN_SLUG --template pytorch --ssh-key SSH_KEY_ID --label cli-test --wait

The command first prints the plan, the disk and the price per hour, and asks Deploy? [y/N]. Answer y. With --wait it waits until the server runs, then prints Server ins_... is running. and the command to connect. Add --yes in scripts to skip the question. If your organization requires approval, the command says the request is waiting; nothing is charged until it is approved.

To see the price, and anything that would refuse the request, without starting a server, add --dry-run. See Check the price before you launch.

The shortest way to a running server is apidly up, which chooses the app and the server the way Quick start does, shows the price and asks before it starts anything. It also sets an automatic stop after --hours of running (default 2):

apidly up notebook --hours 2

5. Connect, check and stop

apidly servers
apidly ssh ins_ID -- nvidia-smi
apidly stop ins_ID --wait
apidly start ins_ID --wait

servers lists your servers with status and price. ssh runs nvidia-smi on the server and prints the GPU table. stop keeps the disk, which is still charged. See Command-line tool for logs, scp and the rest.

6. Delete

apidly destroy ins_ID

It asks you to confirm, because the disk and everything on it are deleted. Use --yes to skip the question. This needs a key with Servers or Full access that an owner or admin created.

7. The same with the API

The command is a thin layer over the public API. Every call sends the key as a bearer token:

curl https://apidly.com/api/v1/me -H "Authorization: Bearer $APIDLY_API_KEY"
curl "https://apidly.com/api/v1/plans" -H "Authorization: Bearer $APIDLY_API_KEY"
curl -X POST https://apidly.com/api/v1/servers/ins_ID/stop -H "Authorization: Bearer $APIDLY_API_KEY"

The first call returns your organization and balance as JSON. The calls and their fields are in the API reference. Ready-made libraries for Python and JavaScript are listed in SDKs.

A script that cleans up after itself

This runs a job and always destroys the server, even if the job fails. It needs jq:

set -euo pipefail
ID=$(apidly deploy --plan PLAN_SLUG --template pytorch --ssh-key SSH_KEY_ID --yes --wait --json | jq -r '.server.id')
trap 'apidly destroy "$ID" --yes' EXIT
apidly ssh "$ID" -- python -c "import torch; print(torch.cuda.is_available())"

More commands for everyday questions

Each line runs as shown once you put in your own IDs, which apidly servers, apidly plans, apidly invoices and apidly templates list.

apidly cost ins_ID
apidly budget status
apidly invoice inv_ID --out invoice.html
apidly export usage --from 2026-11-01 --out usage.csv
apidly refund 5.00 --reason "The server never started and I was charged"
  • apidly cost shows what one server has cost so far, in total and this month.
  • apidly budget status compares this month's spend with your monthly budget.
  • apidly invoice saves one invoice as a page you can open in a browser and print.
  • apidly export usage downloads your usage as a CSV file for a spreadsheet; ledger and activity work the same way.
  • apidly refund asks our staff for money back: it opens a billing ticket, and nothing is paid until a person decides.
apidly filters
apidly watch add PLAN_ID
apidly ports ins_ID
apidly volumes fit PLAN_SLUG
  • apidly filters lists the plan searches you saved on the deploy page.
  • apidly watch add sends you one email when a sold-out plan is available again (the watch lasts 14 days).
  • apidly ports checks whether each port of a running server answers, for example after you start a web app.
  • apidly volumes fit lists your free volumes that a server of that plan could use.
apidly org set --name "My lab"
apidly templates shares tpl_ID
apidly templates use SHARE_TOKEN
  • apidly org set renames your organization or changes its billing email or country.
  • apidly templates shares lists the share links of one of your templates.
  • apidly templates use copies a template someone shared with you into your organization.

When you are done: stop or delete

Check that nothing is left running with apidly servers. Stop keeps the disk, which is still charged. Destroy ends every charge. Revoke a key you no longer need on the API keys page, or with apidly api-keys revoke ID.

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