All articles

Give Claude Code a GPU in 60 seconds

Let Claude Code rent a Lium GPU, run code on it, bring results back and remove it, with a scoped API key, a server-enforced daily budget and automatic removal. Tested on lium.io; the whole run cost under one cent.
Lium team3 min read
claude-code
ai-agents
cli
rtx-5070-ti
Claude Code already runs shell commands, so all it needs to use a GPU is the lium CLI. It can rent a GPU, run code on it, copy results back and remove the pod, with no browser or human involved. The setup needs three things from you:
  • an API key with narrow permissions and a budget;
  • one pip install;
  • a short rules section in CLAUDE.md.
We ran every command below against lium.io on 15 Oct 2026 with CLI 0.16.1. lium up returned a ready RTX 5070 Ti pod in 26 seconds, and the first command output came back 30 seconds after lium up started. The whole run cost $0.006, because Lium bills by the second with no minimum.

1. Make a key just for the agent

Give the agent its own key rather than your account's default key. The quickest way is ADD NEW + on lium.io/api-keys. A key made there can list nodes and rent and manage pods, but it never holds the billing scope, so it can't top up the account or create other keys.
To also cap what the agent spends, create the key with POST /keys and a budget. That call needs your signed-in session token, never an API key. With an email-and-password account you can get the token from /users/login:
bash
API=https://lium.io/api
JWT=$(curl -s $API/users/login -H "Content-Type: application/json" \
  -d '{"email": "you@example.com", "password": "…"}' | jq -r .token)
 
curl -s $API/keys -H "Authorization: Bearer $JWT" -H "Content-Type: application/json" \
  -d '{"name": "claude-code", "scopes": ["read", "rent", "manage"], "daily_budget_usd": 5}'
The response contains the key (sk_…) and echoes the budget ("daily_budget_usd": 5.0): the server stops this key at $5 per UTC day. You can also set monthly_budget_usd, max_budget_usd, or "pod_visibility": "own", which lets the agent see only the pods it rented itself.

2. Install the CLI

bash
pip install lium.io
export LIUM_API_KEY=sk_...      # or: lium config set api.api_key sk_...
lium whoami                     # account, balance, API reachability
If you have no SSH key yet, create one with ssh-keygen -t ed25519; the CLI uses it to reach the pod.

3. Give Claude Code the rules

Add this to your project's CLAUDE.md:
markdown
## GPU compute (Lium)
 
Rent GPUs with the `lium` CLI. The API key is configured; never print it.
- Pick a node with `lium ls --count 1 --format json` (cheapest first) unless I ask for a specific GPU.
- Always rent with a name and a deadline: `lium up <huid> --name <name> --ttl 1h -y --json`.
- Run work with `lium exec <name> "<command>"`; use `lium exec <name> -d "<command>"` for anything long.
- Bring results back with `lium scp <name> <remote-file> <local-dir> -d`.
- When done, or if anything fails: `lium rm <name> -y`, then `lium ps` to confirm.
- If a rent is refused with API_KEY_BUDGET_EXCEEDED, stop and tell me.
Then ask for what you want, for example "benchmark this training script on a GPU and give me the numbers".

4. What Claude Code runs

These are the commands from our test run.
bash
NODE=$(lium ls --count 1 --format json | jq -r '.[0].huid')   # gentle-eagle-11: 1× RTX 5070 Ti, $0.40/h
lium up "$NODE" --name cc-demo --ttl 1h -y --json             # RUNNING in 26 s, removal scheduled in 1 h
lium exec cc-demo "nvidia-smi --query-gpu=name,memory.total --format=csv"
# NVIDIA GeForce RTX 5070 Ti, 16303 MiB
lium exec cc-demo "python -c 'import torch;print(torch.cuda.is_available())'"
# True
lium exec cc-demo "mkdir -p /root/out && nvidia-smi > /root/out/gpu.txt"
lium scp cc-demo /root/out/gpu.txt ./results/ -d
lium rm cc-demo -y && lium ps
lium exec exits with the remote command's exit code, so the agent can branch on success or failure. With --json, lium up prints the ready pod as JSON on stdout and its progress on stderr, which keeps the output easy to parse.

Why this is safe to hand to an agent

  • Scoped key. Without the billing scope, the key can't top up the account, create other keys or raise its own budget. Those actions need your signed-in session.
  • A budget Lium enforces. A rent that would push the key past its daily budget is refused with 402 API_KEY_BUDGET_EXCEEDED, and the key's pods are removed once it reaches the budget. Lium's servers enforce this, whatever the agent does.
  • Automatic removal. --ttl schedules the pod's removal as soon as the pod exists. If the session crashes or is forgotten, the pod is still removed.
  • Per-second billing. A quick GPU experiment costs cents.
Every Lium pod comes with root access and its own Docker daemon, so the agent can docker build and docker run inside it just as it would on a VM.
Run it on Lium
Browse GPUs