Quickstart: rent a GPU with the API

This page takes you from an API key to a running RTX 4090 you can SSH into, then shuts it down. It uses plain HTTP, so it works the same from curl, Python, or an AI agent. Allow about five minutes.

  • API base URL: https://api.green-compute.com
  • Auth: Authorization: Bearer <your API key> on every request except the public ones marked below

0. One-time setup (a human does this once)

An agent with its own wallet can skip this: sign in with the wallet to get a key with two calls, and pay from the same wallet. No email, no card, no sign-up form.

  1. Sign in at green-compute.com/login, with email, Google or a wallet.
  2. Add credit on the Billing page, by card or in crypto (see Adding credit). Starting a rental needs at least one hour of its price in your balance.
  3. Create an API key under Settings → API keys.

Everything after this step is API-only.

export GC_KEY="paste-your-api-key"
export GC_API="https://api.green-compute.com"

1. Check price and availability (public, no key)

curl -s "$GC_API/platform/pricing"
curl -s "$GC_API/platform/nodes/supported"

/platform/pricing is the exact rate billing charges, and its available_now says whether each GPU can be rented right now (availability adds almost_fully_rented when few are left; counts aren't published). /platform/nodes/supported lists the GPU ids that have a machine online (currently ["rtx4090"]); any spelling works on input ("RTX 4090", "rtx-4090"). Asking for a GPU that isn't in that list fails immediately with a 400 that names what is available; asking for one that is listed but fully_rented fails immediately with a 503 and a Retry-After, and you can join the waitlist instead.

2. Describe the machine you want

A workload says what to run: the image and the hardware. Put your own SSH public key in metadata.ssh_public_keys so you can log in with a key you already hold.

WORKLOAD_ID=$(curl -s -X POST "$GC_API/platform/workloads" \
  -H "Authorization: Bearer $GC_KEY" -H "Content-Type: application/json" \
  -d '{
    "name": "my-gpu-box",
    "kind": "pod",
    "image": "pytorch/pytorch:2.7.0-cuda12.8-cudnn9-runtime",
    "requirements": {
      "gpu_count": 1,
      "supported_gpu_models": ["rtx4090"],
      "min_vram_gb_per_gpu": 24,
      "cpu_cores": 8,
      "memory_gb": 32
    },
    "metadata": {
      "ssh_public_keys": ["'"$(cat ~/.ssh/id_ed25519.pub)"'"],
      "volume_size_gb": 50
    }
  }' | python3 -c 'import sys,json; print(json.load(sys.stdin)["workload_id"])')
echo "$WORKLOAD_ID"

3. Start it

A deployment is a running instance of the workload. Billing starts when it reaches ready, so time spent pulling the image is free.

RENTAL_KEY=$(python3 -c 'import uuid; print(uuid.uuid4())')  # reuse it if you retry
DEPLOYMENT_ID=$(curl -s -X POST "$GC_API/platform/deployments" \
  -H "Authorization: Bearer $GC_KEY" -H "Content-Type: application/json" \
  -H "Idempotency-Key: $RENTAL_KEY" \
  -d "{\"workload_id\": \"$WORKLOAD_ID\", \"max_runtime_minutes\": 60}" \
  | python3 -c 'import sys,json; d=json.load(sys.stdin); print(d["deployment_id"]); print("rate cents/GPU/hr:", d["hourly_rate_cents"], file=sys.stderr)')

max_runtime_minutes stops the rental automatically after an hour, so a script that dies can't leave it billing; raise or drop it for longer jobs. The Idempotency-Key header makes a retried request return the first rental instead of starting a second one (see Retrying a create safely).

hourly_rate_cents in the response is the most this deployment can cost per GPU-hour. With a single GPU model it is the exact rate. Once a GPU is assigned, the field updates to that card's rate, which is never higher. There is no deployment fee: deployment_fee_usd is always 0.

4. Wait until it is ready

while true; do
  STATE=$(curl -s "$GC_API/platform/deployments/$DEPLOYMENT_ID" -H "Authorization: Bearer $GC_KEY" \
          | python3 -c 'import sys,json; print(json.load(sys.stdin)["state"])')
  echo "$STATE"
  case "$STATE" in ready) break ;; failed|terminated) exit 1 ;; esac
  sleep 10
done

States run pending → scheduled → pulling → starting → ready. Usually this takes one to three minutes; the first pull of a large image takes longer.

5. Connect

curl -s "$GC_API/platform/deployments/$DEPLOYMENT_ID/ssh" -H "Authorization: Bearer $GC_KEY"
# {"ssh_host": "...", "ssh_port": 40123, "ssh_username": "root", "ssh_command": "ssh root@... -p 40123", "private_key": null}
ssh root@<ssh_host> -p <ssh_port> nvidia-smi

Your public key from step 2 is the only key that can log in, so private_key is null. A client that supplies no key gets a platform-generated one there instead.

The image's environment carries over into SSH sessions, so python and conda work exactly as the image defines them. Persistent storage is mounted at /workspace.

6. Stop it (this stops billing)

curl -s -X DELETE "$GC_API/platform/deployments/$DEPLOYMENT_ID" -H "Authorization: Bearer $GC_KEY"

Billing is per started minute while it runs (startup is free), so you pay only for the minutes it ran.

Next