For AI agents
This page is for an AI agent (or its developer) that has been pointed at Green Compute and needs to use it without a human clicking through a dashboard.
What Green Compute is
GPU compute on Bittensor subnet 110, run on renewable and biogas power. Two products, both over one HTTP API:
- GPU rental: an SSH-accessible container on an RTX 4090, billed per started minute (startup is free). See Quickstart.
- Inference: OpenAI-compatible chat completions. See Inference.
Machine-readable entry points
| What | URL | Auth |
|---|---|---|
| This documentation, as one file | https://www.green-compute.com/llms-full.txt | none |
| Documentation index | https://www.green-compute.com/llms.txt | none |
| Any docs page as Markdown | append .md, e.g. https://www.green-compute.com/docs/quickstart.md | none |
| OpenAPI spec | https://api.green-compute.com/openapi.json | none |
| API index | https://api.green-compute.com/ | none |
| Prices | https://api.green-compute.com/platform/pricing | none |
| GPU ids you can rent right now | https://api.green-compute.com/platform/nodes/supported | none |
| Your balance / billing history | /platform/billing/balance, /platform/billing/ledger | API key |
What needs a human
Nothing, if you have a wallet: sign in with it to create the account and get an API key, and pay from the same wallet. No email, no card, no sign-up form, no browser.
Without a wallet, a person creates the account and the API key in the browser once; after that, everything is API. Point them at green-compute.com/settings, and at green-compute.com/billing if they'd rather pay by card.
Sign in with a wallet
An agent with its own wallet goes from nothing to a running GPU on its own. The wallet is the account:
POST /platform/auth/wallet/challengewith your address: a one-time message to sign.- Sign it with the wallet, locally (no call).
POST /platform/auth/wallet/verifywith the signature: the API key, created with the account the first time.- Send USDC or USDT (Base or Ethereum), TAO or alpha from that wallet to the deposit address in the reply. It is added to your balance a few minutes later, with no invoice and no amount to match.
- Rent with the key, exactly as in the Quickstart.
EVM wallets (Ethereum, Base) sign a Sign-In with Ethereum message (EIP-4361) with personal_sign; Bittensor wallets sign with the coldkey you pay from (sr25519). Smart-contract wallets can't sign in: use a wallet with its own key.
import json, os, urllib.request
from eth_account import Account # pip install eth-account
from eth_account.messages import encode_defunct
API = "https://api.green-compute.com"
wallet = Account.from_key(os.environ["WALLET_PRIVATE_KEY"])
def post(path, body):
req = urllib.request.Request(API + path, data=json.dumps(body).encode(), method="POST",
headers={"Content-Type": "application/json"})
with urllib.request.urlopen(req) as r:
return json.loads(r.read())
challenge = post("/platform/auth/wallet/challenge", {"address": wallet.address})
signature = wallet.sign_message(encode_defunct(text=challenge["message"])).signature.hex()
signed_in = post("/platform/auth/wallet/verify", {
"nonce": challenge["nonce"], "signature": signature,
# optional: limit the key from day one
"daily_spend_limit_usd": 20, "max_active_rentals": 1,
})
GC_KEY = signed_in["api_key"] # shown only now: store it
print(signed_in["deposit_addresses"]) # where to send funds from this wallet
With a Bittensor coldkey, sign the same way with substrate-interface:
from substrateinterface import Keypair # pip install substrate-interface
coldkey = Keypair.create_from_mnemonic(os.environ["COLDKEY_MNEMONIC"])
challenge = post("/platform/auth/wallet/challenge", {"address": coldkey.ss58_address})
signed_in = post("/platform/auth/wallet/verify", {
"nonce": challenge["nonce"], "signature": "0x" + coldkey.sign(challenge["message"]).hex()})
From a terminal, btcli wallet sign --wallet-name <name> --no-use-hotkey --message '<message>' prints the signature. With curl:
curl -s -X POST https://api.green-compute.com/platform/auth/wallet/challenge \
-H "Content-Type: application/json" -d '{"address": "0xYourAddress"}'
# {"nonce": "9f3c…", "message": "www.green-compute.com wants you to sign in with your Ethereum account:\n0xYour…",
# "expires_at": "2026-11-16T12:05:00Z", "domain": "www.green-compute.com", ...}
curl -s -X POST https://api.green-compute.com/platform/auth/wallet/verify \
-H "Content-Type: application/json" -d '{"nonce": "9f3c…", "signature": "0x…"}'
{
"api_key": "gk_…",
"key_id": "…",
"key_name": "wallet sign-in",
"scopes": [],
"user_id": "…",
"account_created": true,
"wallet": {"chain": "evm", "address": "0xyouraddress"},
"revoked_key_ids": [],
"account_limits": {"max_active_rentals": 2, "daily_spend_limit_usd": 50.0, "until": "2026-11-23T12:00:01+00:00",
"lifts_after_deposit_usd": 20.0, "deposited_usd": 0.0},
"deposit_addresses": [{"currency": "usdc-base", "deposit_address": "0x…", "bonus_pct": 0.0}],
"credited": [],
"next_steps": ["…"]
}
What to know:
-
Sign the message exactly as given, within 5 minutes. Each message works once and names
www.green-compute.com: a signature for any other site, or for another wallet, doesn't sign in. -
Lost the key? Sign in again. Each sign-in issues a new key and revokes the keys this wallet's earlier sign-ins issued and every key made with them (with
POST /platform/api-keys), all listed inrevoked_key_ids. So an agent that signs in again loses the sub-keys it made, unless it sends"keep_existing_keys": true, which adds a key and revokes nothing. Website sessions the wallet began have keys of their own and keep them, so an agent signing in doesn't sign a person out. The account's other keys (the website's key for email sign-in, and keys made with it) are never touched. -
Shut a wallet out completely with a challenge with
"action": "revoke_keys", verified: it revokes every key the wallet's sign-ins issued, over the API and on the website, and keys made with them, and issues none. Unlinking the wallet, or turning its sign-in off, does the same. -
Limit the key from the start:
scopes,max_active_rentals,daily_spend_limit_usdandexpires_in_days(orexpires_at) work as for any key. -
New wallet accounts can have 2 rentals running at once and spend $50 in any 24 hours, for their first 7 days, whichever key they use (
account_limitsin the reply; going over returns403witherror.codenew_account_limit, for starting rentals and for model requests alike). Paying in $20 in crypto lifts this at once: payments in TAO, alpha, USDC or USDT that have been credited to the account, added up (lifts_after_deposit_usd, anddeposited_usdso far). It counts what you paid: the 10% alpha bonus, card payments and credits from our staff don't count. So it is still no email and no card. Adding an email to the account on the website, under Settings, lifts it too. The403says how much more to pay in, anddetail.untilwhen it ends anyway. -
Paying: every payment from this wallet to our deposit addresses is credited to the account at the current price, whatever the amount. Watch for the
payment.creditedevent, or pollGET /platform/billing/balance. Payments the wallet sent in the last 30 days that weren't credited to anyone are credited when it signs in (credited). -
A wallet you verified on an existing account to pay in (Billing → Verified wallets) doesn't sign in until you tick Sign in with this wallet next to it there (or
PATCH /platform/billing/wallets/{wallet_id}with{"sign_in": true}, with a full-access key); until then, signing in with it returns403wallet_sign_in_off. Once on, it signs in to that account, not a new one. Each wallet belongs to one account. The account's owner is emailed when a wallet's sign-in is turned on. -
Letting another wallet sign in needs your wallet's signature when the account already has a wallet that signs in, so a leaked key can't plant a way back in. Ask for a challenge from a wallet that signs in, naming the new one, sign it, and send it with the change:
curl -s -X POST https://api.green-compute.com/platform/auth/wallet/challenge -H "Content-Type: application/json" \ -d '{"address": "<a wallet that signs in>", "action": "approve_sign_in", "subject": "evm:<the new wallet>"}' curl -s -X PATCH https://api.green-compute.com/platform/billing/wallets/<wallet_id> \ -H "Authorization: Bearer $GC_KEY" -H "Content-Type: application/json" \ -d '{"sign_in": true, "nonce": "<from the challenge>", "signature": "<signature>"}'Without it the change returns
403approval_required, listing indetail.sign_withthe wallets that can sign. Adding an email to a wallet account on the website asks for the same kind of signature ("action": "add_email"). -
On the website, the same wallet signs in with Connect wallet on the sign-in page.
-
Every wallet is checked against public sanctions lists before it can sign in, pay or rent. A wallet that fails gets
403wallet_blocked: "This wallet can't be used with Green Compute. Contact support@green-compute.com." -
Errors to handle:
challenge_invalid(unknown, used or expired message: ask for a new one),signature_invalid(wrong key or an altered message: ask for a new one),wallet_sign_in_offandapproval_required(see above),screening_unavailable(new wallets can't be checked right now: try again in a few minutes),rate_limited(too many sign-in requests right now: wait theRetry-Afterseconds and try again). See Errors.
Adding credit over the API
An agent with its own wallet can fund the account without a person. There are two ways; a verified wallet is the simpler one. Adding credit covers the same ground for people, including what to do when a payment isn't credited.
Option A: verify your wallet once, then just pay
If you signed in with your wallet, it is verified already: skip to step 3.
1. Ask for a message to sign for the wallet you'll pay from. chain is bittensor (for TAO and alpha) or evm (for USDC and USDT on Ethereum and Base):
curl -s -X POST https://api.green-compute.com/platform/billing/wallets/challenge \
-H "Authorization: Bearer $GC_KEY" -H "Content-Type: application/json" \
-d '{"chain": "bittensor", "address": "<your coldkey address>"}'
{
"chain": "bittensor",
"address": "<your coldkey address>",
"issued_at": "2026-10-12T12:00:00Z",
"message": "Green Compute: link wallet <address> to account <you>. Issued 2026-10-12T12:00:00Z. Payments from this wallet will be credited to this account."
}
2. Sign message with that wallet's key, and send the signature back within 15 minutes:
# A Bittensor coldkey, with substrate-interface
from substrateinterface import Keypair
signature = Keypair.create_from_mnemonic(MNEMONIC).sign(challenge["message"]).hex()
# An Ethereum / Base account, with eth-account
from eth_account import Account
from eth_account.messages import encode_defunct
signature = Account.sign_message(encode_defunct(text=challenge["message"]), private_key=KEY).signature.hex()
From a terminal, btcli wallet sign --wallet-name <name> --no-use-hotkey --message '<message>' prints the same signature.
curl -s -X POST https://api.green-compute.com/platform/billing/wallets \
-H "Authorization: Bearer $GC_KEY" -H "Content-Type: application/json" \
-d '{"chain": "bittensor", "address": "<your coldkey address>", "issued_at": "<from step 1>", "signature": "<hex>"}'
3. Pay any amount, any time. Send from that wallet to the address for the currency, listed by GET /platform/billing/crypto/addresses. It is credited at the current price a few minutes after the transfer confirms, and GET /platform/billing/crypto/deposits lists every credited payment.
Linking a wallet also credits anything it sent us in the last 30 days that wasn't credited to anyone. Each wallet can be verified by one account. Exchange accounts and smart-contract wallets can't sign messages; pay those with an invoice.
Option B: an invoice for an exact amount
1. Create an invoice for the amount you want to add, in US dollars ($1 to $50,000):
curl -s -X POST https://api.green-compute.com/platform/billing/topup/crypto \
-H "Authorization: Bearer $GC_KEY" -H "Content-Type: application/json" \
-d '{"currency": "usdc-base", "amount_usd": 20}'
{
"invoice_id": "<id>",
"currency": "usdc-base",
"amount_crypto": 20.003817,
"amount_to_send": "20.003817",
"amount_usd": 20.0,
"bonus_pct": 0.0,
"total_credits": 2000,
"deposit_address": "<address to send to>",
"expires_at": "2026-10-12T12:30:00+00:00"
}
2. Send exactly amount_to_send of that currency to deposit_address before expires_at, 30 minutes after you create the invoice. Everyone pays to the same address, so the last digits are what identify your invoice: send that exact string as one transfer, and don't round it. Paying up to 5% more is accepted when no other open invoice could match, and credits the full value received. The exact amount arriving after the invoice expired is still matched for 24 hours, at the price when it arrives. For TAO, use a normal transfer, not transfer_all, which deducts the fee and arrives short. A smaller amount or a split payment isn't matched automatically: verify the wallet it came from (Option A), which credits it, or request a review with POST /platform/billing/crypto/{invoice_id}/review and {"tx_hash": "...", "note": "..."}, which support checks by hand.
3. Wait for the credit. Poll GET /platform/billing/crypto/invoices until your invoice's status is confirmed, or watch GET /platform/billing/balance. An account can have five unpaid invoices open at once.
currency | What to send | Bonus |
|---|---|---|
usdc-base, usdt-base | USDC or USDT on Base | none |
usdc-eth, usdt-eth | USDC or USDT on Ethereum | none |
tao | TAO, as a plain transfer on Bittensor | none |
alpha | Subnet 110 alpha, moved to the deposit address with transfer_stake (btcli stake transfer) | 10% extra credit |
ETH itself and other tokens aren't accepted. To pay by card instead, POST /platform/billing/topup/stripe with {"amount_usd": 20} returns a checkout_url that a person has to open and pay.
Rules of thumb
- Use your own SSH public key in
metadata.ssh_public_keys. Then you never need to fetch, store or log a private key. - Budget from the API, not from prose.
hourly_rate_centson a new deployment is the most it can cost per GPU-hour;/platform/pricingis what billing charges. - Let a fleet keep your rentals running.
POST /platform/fleets{"workload_id": "…", "target": 8}replaces any rental that stops, under the same name, and waits for GPUs or credit by itself; see Fleets. - Watch your credit.
GET /platform/billing/forecastgiveshours_leftat the current burn; the account owner is emailed under 24 hours and under 2 hours. Create saved pods withresume_on_topup: trueand they come back by themselves after a top-up, so your loop never has to notice a pause. - Always clean up, and set a backstop.
DELETE /platform/deployments/{id}stops billing; wrap your work so it runs even on failure. Also passmax_runtime_minuteswhen you create the deployment, so it stops by itself if you crash. To confirm,GET /platform/deployments/{id}showsterminated, and/platform/billing/ledgershows what was charged. - Use MCP if your client speaks it.
https://api.green-compute.com/mcpexposes renting, status, logs, stats and events as tools; see MCP. - Don't poll every deployment.
GET /platform/events?after=<cursor>returns every change on the account since the last call (ready, failed, suspended, terminated, balance low), or register a webhook. See Events and webhooks. - Change a card without SSH.
POST /platform/deployments/{id}/execruns a command in it and returns the exit code and output; loop over your rentals to update them all. Withrestart_policy, stopping the job restarts it on the new version. - Check a card without SSH.
GET /platform/deployments/{id}/statshas each GPU's use, temperature, power and clocks;GET /platform/deployments/{id}/logshas the job's recent output. - Keep tokens out of your requests. Save them once with
POST /platform/secretsand name them in a pod'smetadata.secret_env({"HF_TOKEN": "hf-read"}): the values never appear in any response, transcript or log of yours. See Secrets. - Run jobs without SSH. Put the job in the workload's
metadata.commandand its settings inmetadata.env(tokens inmetadata.secret_env); it starts on its own when the pod is ready, logging to/workspace/greencompute-command.log. Add"restart_policy": "on-failure"(or"always") to have it run again if it exits, instead of watching for crashes yourself. Pair it withmax_runtime_minutes. - Make creates retry-safe. Send an
Idempotency-Keyheader onPOST /platform/workloadsandPOST /platform/deployments. If a request times out, resend it with the same key: you get the first result back instead of a second rental. - Check
available_nowbefore you create, and respectRetry-After./platform/pricingsays whether each GPU can be rented this instant (available_now, andavailability:available,almost_fully_rented,fully_rentedoron_request); it doesn't publish counts. If a GPU isfully_rented, join the waitlist (POST /platform/capacity-alerts, or a webhook forcapacity.available) rather than polling. A503 no_capacity(no room) or a429(rate limit) says how many seconds to wait in itsRetry-Afterheader; neither creates anything. Each key may send 20 requests a second on average (bursts of 40); every response'sX-RateLimit-Remainingsays how many it may send right now (see Limits). - Poll, don't sleep blindly.
GET /platform/deployments/{id}every 5–10 s untilstateisready; stop onfailedand readlast_error. - Branch on
error.code. Every error haserror.code(stable),error.retryableand, when it applies,error.retry_after_seconds; see Errors. Don't match message text. - Errors are actionable. A
400for an unavailable GPU lists the GPUs that are available; a402gives the exact amount to top up, which you can pay with a crypto invoice. See Errors. - For an RTX 5090, use a CUDA 12.8+ image.
pytorch/pytorch:2.7.0-cuda12.8-cudnn9-runtimeworks on both cards. - One-off commands work over SSH.
ssh root@host -p port 'python train.py'uses the image'sPATH, so conda/PyTorch images behave as documented.
Give your agent a limited key
A key can be limited to some of these scopes, so a leaked or prompt-injected key can only do what you allowed:
| Scope | Allows |
|---|---|
read | Seeing deployments, workloads, balance, invoices and other account data |
inference | Calling models through /v1 |
rentals | Starting, changing and stopping rentals, managing secrets, and getting SSH access |
billing | Adding credit: crypto invoices, verified wallets, payment reviews |
keys | Creating and revoking keys, never broader than itself |
Create one under Settings → API Keys → Limited, or with an existing key:
curl -s -X POST https://api.green-compute.com/platform/api-keys \
-H "Authorization: Bearer $GC_KEY" -H "Content-Type: application/json" \
-d '{"name": "my-agent", "scopes": ["read", "rentals"], "max_active_rentals": 2, "daily_spend_limit_usd": 10,
"expires_in_days": 7}'
Add limits so a leaked or runaway key can't drain the account: "max_active_rentals": 2 caps how many rentals it may have running at once, and "daily_spend_limit_usd": 10 caps what it may spend on rentals and inference in any 24 hours (saved-pod storage isn't counted). At the spend limit the key can't start rentals or call models, and rentals it started are paused (state: "suspended", suspended_reason: "spend_limit", the reason in last_error), kept as when credit runs out: see Paused at a spend limit. A key with limits of its own can't create keys (403; each new key would start a fresh 24-hour budget): create keys under Settings, or with a key without limits. An expiring key can create keys, which expire no later than it does.
Make the key expire so a forgotten one stops working on its own: "expires_in_days": 7 (1 to 365), or "expires_at": "2026-12-01T00:00:00Z" (ISO 8601, at most 365 days away; send one or the other). Left out, the key never expires. A key made with an expiring key never outlives it: it expires when that key does, or sooner if you ask. GET /platform/api-keys shows each key's expires_at (null: never) and expired. After its expiry every request with the key returns 401 with error.code api_key_expired and the time it expired; create a new key under Settings, or with another key. Rentals the key started keep running after it expires: they belong to the account, so stop them with another key (or under Rentals) when you're done. A fleet the key created pauses instead of starting more.
The response holds the new key's secret, shown only once. A key with no scopes has full access, like the one your dashboard uses. A request outside a key's scopes returns 403 with required_scope in the body; a request over a key's limits returns 403 with "code": "key_limit".
Limits for the whole account
To stop everything at $X, whichever key spends it, set limits on the account itself: under Settings → Account limits, or with a full-access key:
curl -s -X PUT https://api.green-compute.com/platform/account/limits \
-H "Authorization: Bearer $GC_KEY" -H "Content-Type: application/json" \
-d '{"daily_spend_limit_usd": 100, "max_active_rentals": 10}'
{
"daily_spend_limit_usd": 100.0,
"max_active_rentals": 10,
"spent_last_24h_usd": 12.34,
"active_rentals": 3,
"new_account_limits": null,
"in_force": {"daily_spend_limit_usd": 100.0, "daily_spend_limit_source": "account",
"max_active_rentals": 10, "max_active_rentals_source": "account"}
}
daily_spend_limit_usd(at least $1) caps what the account spends in any 24 hours, by every key together and the website: rentals, private models and model requests. Saved-pod storage ($1/day) isn't counted, so paused pods never keep you at a limit. At it, starting a rental and calling a model return403account_spend_limit_reached, and running rentals are paused, exactly as at a key's own spend limit: see Paused at a spend limit. Starting and calling work again as earlier spending falls out of the 24-hour window, or when you raise the limit.max_active_rentals(1 to 1000) caps how many rentals and private models the account has running, starting or paused at once. Over it, starting another returns403account_rental_limit_reached. Lowering it below what runs now stops nothing; it refuses new ones until enough have ended.PUTsets both: one left out ornullmeans no limit.PATCHchanges only the fields you send, e.g.{"max_active_rentals": null}to clear one.- Any key of the account can read them with
GET /platform/account/limits, which also gives what was spent in the last 24 hours and how many rentals are running, so an agent can see how close it is. Only a full-access key can change them: a read-only, rent-only or other scoped key gets403scope_required. Raising or clearing a limit needs a key with full access and no limits or expiry of its own, such as the website's (Settings): any other full-access key may only lower a limit or set one where there is none, and gets403unrestricted_key_requiredotherwise (detail.looseningnames the fields).PUTcounts as raising for any field it clears by leaving it out. So a leaked agent key can't lift the cap that stops it. - Fleets wait at these limits, as they do at a key's, and say so in their
status. A keep-N-running fleet whose members were paused at a spend limit brings them back by itself, rather than starting replacements: see Paused at a spend limit. - Both kinds of limit apply together: a request has to fit its key's limits and the account's. For a new wallet account in its first week, the lower of its own limits and the first-week ones applies (
in_forceshows which; going over a first-week one still returnsnew_account_limit).new_account_limitssays what ends them early:lifts_after_deposit_usdpaid in crypto (deposited_usdso far), or an email; it isnullonce they no longer apply.
Paused at a spend limit
At a spend limit (the account's, a key's for the rentals it started, or a new wallet account's first-week one), running rentals and private models are paused rather than deleted, the same way as when credit runs out (Running out of balance):
statebecomessuspended, withsuspended_reason: "spend_limit"(also in thedeployment.suspendedevent) and the reason inlast_error, e.g.paused: its account reached its spend limit of $100.00 for the last 24 hours (Settings > Account limits).- The container stops and GPU billing stops. A pod's disk is kept as when credit runs out: a saved pod (
save_on_exhaustion: true) for up to 30 days, still charged $1 a day for storage (which isn't counted against any spend limit); an unsaved one is deleted 15 minutes later.deletes_atsays when. A paused private model isn't deleted: it stays paused (and counts towardsmax_active_rentals) until you resume or delete it. - When it comes back:
- In a keep-N-running fleet (
replace: true): by itself. The fleet resumes its own paused members, oldest first, instead of replacing them, once every spend limit on them has room for an hour of everything that would then run under it and the balance covers an hour of it on top of what runs; until then itsstatussays how many are paused at a spend limit. If a member's limit has room but its machine is gone, the fleet deletes that member and starts a replacement under the same name (last_error: "replaced by its fleet: its machine couldn't take it back"). If its machine is only full, a saved member (save_on_exhaustion: true) is never deleted for it: the fleet keeps it and tries again every pass, and itsstatussays it is waiting for room on its machine (delete it on My Rentals to get a replacement elsewhere). An unsaved one is replaced once its machine has had no room for about 2 minutes (3 passes). A start-N fleet (replace: false) doesn't resume them itself. - Rentals with
resume_on_topup(outside a keep-N-running fleet): by itself, on the same rule. - Others: when you resume it, with
POST /platform/deployments/{id}/resume(or Resume on My Rentals). That works as soon as the account's spending, and that of the key that started it, is back under the limit, or after you raise the limit; until then it returns403with the same code (account_spend_limit_reached,key_limitornew_account_limit). - "Room for an hour" keeps paused rentals from flapping: with less, they would be paused again within the hour. It counts what already runs under that limit, so a few rentals come back at a time as earlier spending leaves the 24-hour window. It doesn't count rentals started later or model requests, so a rental that came back can still be paused again if more is spent under the same limit.
- A rental whose hour costs more than the whole limit (a $5-an-hour rental under a $4 limit, say) never has room for an hour, so it doesn't come back by itself: raise the limit, then resume it.
- Nothing comes back by itself once the API key that started it (and whose limit may have paused it) is deleted or has expired: deleting a capped key doesn't lift its cap. You can still resume it yourself, with another key or on the website; a fleet whose key is gone pauses, as it does whenever its key is deleted.
- In a keep-N-running fleet (
- A pod paused for an empty balance that would resume after a top-up also waits until the spend limits have room for an hour of it.
Minimal loop (Python, standard library only)
import json, os, time, urllib.request
API = "https://api.green-compute.com"
KEY = os.environ["GC_KEY"]
def call(method, path, body=None):
req = urllib.request.Request(
API + path, method=method,
data=json.dumps(body).encode() if body is not None else None,
headers={"Authorization": f"Bearer {KEY}", "Content-Type": "application/json"},
)
with urllib.request.urlopen(req) as r:
return json.loads(r.read() or b"null")
pubkey = open(os.path.expanduser("~/.ssh/id_ed25519.pub")).read().strip()
wl = call("POST", "/platform/workloads", {
"name": "agent-job", "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": [pubkey]},
})
dep = call("POST", "/platform/deployments", {"workload_id": wl["workload_id"], "max_runtime_minutes": 60})
try:
while (d := call("GET", f"/platform/deployments/{dep['deployment_id']}"))["state"] not in ("ready", "failed"):
time.sleep(10)
if d["state"] == "failed":
raise RuntimeError(d.get("last_error"))
ssh = call("GET", f"/platform/deployments/{dep['deployment_id']}/ssh")
print("connect with:", ssh["ssh_command"])
# ... do the work over SSH ...
finally:
call("DELETE", f"/platform/deployments/{dep['deployment_id']}")
Green Compute