# Check the price before you launch

Before a script starts a GPU server, it can ask what that server would cost and whether the request would be accepted today. This is a dry run: every check of a real request runs, but nothing is created, charged or recorded. It is free. You need the `apidly` command (see [Use the CLI and API from scratch](/docs/tutorial-cli-and-api)) and an API key with **Servers** or **Full access**.

## 1. Run a dry run from the CLI

Write the `deploy` command you would run, and add `--dry-run`:

```bash
apidly plans --available --sort price --limit 5
apidly deploy --plan PLAN_SLUG --template pytorch --disk 40 --label price-check --dry-run
```

The first command lists plans you can request now; copy a `SLUG`. The second asks no question and starts nothing.

## 2. Read the answer

You see lines like these, with today's prices:

```text
Plan:      1x GPU_MODEL (PLAN_SLUG)
Template:  TEMPLATE_NAME (pytorch)
Disk:      40 GB
Running:   $… per hour ($… compute + $… disk)
Stopped:   $… per hour for the disk, until you destroy the server
The request passes every check.
Nothing was created. Run the same command without --dry-run to deploy.
```

- **Running** is what the server costs per hour while it runs: compute plus disk.
- **Stopped** is what is still charged while it is stopped: the disk only, until you destroy the server.
- With `--fallback-plan`, an **At most** line shows the highest hourly price if a fallback plan is used.

## 3. Read the blockers

Instead of **The request passes every check.**, you may see **Would be refused today:** followed by one line per problem, each with a code and what to do:

- `insufficient_balance`: your balance is too low for this server. Add credit on **Billing**.
- `budget_reached`: your organization's monthly budget is used up. Raise or remove it under **Settings**.
- `key_limit_reached`: this API key has reached its own monthly spending limit.

A blocker does not hide the price, so you can see the cost even before you add credit. A request that could never work, for example an unknown plan, a disk size out of range or a plan that is out of stock, is not a blocker: the command stops with the error, just as a real deploy would.

## 4. The same through the API

Send the body of a real request to `POST /api/v1/servers` with `?dryRun=1`. Use the `id` values of `GET /api/v1/plans` and `GET /api/v1/templates`:

```bash
curl -X POST "https://apidly.com/api/v1/servers?dryRun=1" \
  -H "Authorization: Bearer $APIDLY_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"planId": "PLAN_ID", "templateId": "TEMPLATE_ID", "label": "price-check", "diskGb": 40}'
```

The answer is `200` with `"dryRun": true` and a `quote`: `totalHourlyUsd` (running), `hourlyPriceUsd` (compute), `storageHourlyUsd` (disk), `balanceUsd`, `requiredBalanceUsd` and `blockers`, a list of `code` and `message`. An empty `blockers` list means a real request would pass. Dry runs have their own limit of 30 a minute per key, so they never use up your launch allowance.

## 5. The same from an SDK

JavaScript:

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

const apidly = new Apidly({ apiKey: process.env.APIDLY_API_KEY });
const { quote } = await apidly.servers.estimate({
  planId: "PLAN_ID",
  templateId: "TEMPLATE_ID",
  label: "price-check",
  diskGb: 40,
});
if (quote.blockers.length > 0) {
  console.log(quote.blockers.map((b) => b.message).join("\n"));
} else {
  console.log(`About ${quote.totalHourlyUsd} USD per hour while running`);
}
```

Python:

```python
import os
from apidly import Client

client = Client(api_key=os.environ["APIDLY_API_KEY"])
quote = client.servers.estimate(
    plan_id="PLAN_ID", template_id="TEMPLATE_ID", label="price-check", disk_gb=40
)["quote"]
print(quote["totalHourlyUsd"], [b["code"] for b in quote["blockers"]])
```

## What it costs and how to stop spending

A dry run costs nothing and starts nothing, so there is nothing to stop. When you deploy for real, the server is charged from the moment it runs. Stop it with `apidly stop ins_ID` (the disk is still charged) or destroy it with `apidly destroy ins_ID` to end every charge.

## Next

- [Keep an eye on spending from scripts](/docs/tutorial-spending-from-scripts)
- [Control costs: stop, auto-stop, budgets and auto top-up](/docs/tutorial-save-money)
