Examples
Five conversations with an agent that uses Legion, and the tool calls behind them, each showing where the agent asks before it acts.
Each example shows what you say, the tool calls the agent makes, and where it stops to ask you. The names, IDs and addresses are made up. Where a price or an amount would be, the examples show it in square brackets: the agent reads the real one from the offer, the preview or your balance.
Run a small text model, and ask before renting
You say:
Run a small text model on the cheapest GPU that can hold it, and show me my options. Don't rent anything yet.The agent reads. It starts with Legion's catalog of premade images and models, then asks for the hosts that can run the entry it picked. These are read-only tools, so it needs no confirmation:
{ "name": "list_catalog", "arguments": {} }{ "name": "list_offers", "arguments": { "catalog_id": "qwen3-5-4b", "sort": "price", "limit": 3 } }{ "name": "get_billing_account", "arguments": {} }{ "name": "list_ssh_keys", "arguments": {} }list_ returns the premade entries, each with an id, a reference and, for a model, a serve block. The agent picked the kind: model entry qwen3-5-4b, and list_ with that catalog_ returns only hosts that can run it. It answers in its own words:
Legion has a premade Qwen3.5 4B text model. Three hosts can run it. The cheapest is amber-falcon:
2 GPUs free, score [score], 30-day uptime [uptime], [price] per GPU-hour. The next two cost a little
more but score higher. Your balance is [balance].
Your saved SSH keys are "laptop" and "work". Which host and key do you want?You say:
Rent one GPU on amber-falcon with the laptop key and run that model.Now the agent is about to spend credit, so it asks the server for a preview. It sends the call without confirm:
{
"name": "create_rental",
"arguments": {
"idempotency_key": "6f1c2b8e-3d4a-4f5e-9b7c-2a1d0e8f9c3b",
"body": {
"host_id": "8c0e2f4a-1b3d-4e5f-9a7b-6c5d4e3f2a1b",
"gpu_count": 1,
"image": "[the entry's reference from list_catalog]",
"ssh_public_key": "ssh-ed25519 AAAA… you@laptop",
"serve": { "port": 8000, "kind": "openai", "model": "Qwen/Qwen3.5-4B", "catalog_id": "qwen3-5-4b" }
}
}
}The agent takes port, kind (the entry's serve.), model and catalog_ from the entry. Nothing is created. The result is a confirmation_ preview with the price, your balance, the SSH key and the image. The agent shows it to you:
Before I rent this, please check it:
- Host amber-falcon, 1 GPU, running the premade Qwen3.5 4B model. This exposes the model at an HTTPS address on ambi.run, and callers need an API key.
- [price] per GPU-hour, so [hourly total] an hour, billed by the second from the moment it runs.
- Image: Legion's premade Qwen3.5 4B. SSH key "laptop", one of your saved keys.
- Your balance is [balance], which lasts about [hours] hours at that rate.
Shall I rent it?You say yes. Only now the agent repeats the call, with confirm: true and expected_ and expected_ set to the values in the preview. The same idempotency_ means a retry can't rent twice. If the price had changed since the preview, the call would be refused and the agent would ask again.
It then calls get_ every few seconds until state is running, and gives you the command:
ssh -J ssh.legion.ambient.xyz:22 -o HostKeyAlias=quiet-river-7k2f root@quiet-river-7k2fCheck my spend this week
You say:
How much did I spend on Legion in the last seven days, and how long will my credit last?Everything here is read-only, so the agent doesn't ask:
{ "name": "list_billing_activity", "arguments": { "account": "balance", "limit": 50 } }{ "name": "get_billing_account", "arguments": {} }{ "name": "list_rentals", "arguments": { "limit": 100 } }The agent adds up the charges of the rental_ items from the last seven days, in cents, and reads the price and GPU count of each running rental to estimate how long your balance lasts:
In the last seven days Legion billed you [total] for [number] rental sessions. One rental is
still running, at [hourly rate] an hour. Your balance is [balance], which lasts about [hours]
hours at that rate. That is an estimate: stopped rentals also bill for storage.If the activity list has more pages, the agent follows next_ until it passes seven days. It says what it added up, so you can check.
Stop everything I'm not using
You say:
I'm done for today. What's still running, and what is it costing me?The agent reads:
{ "name": "list_rentals", "arguments": { "limit": 100 } }{ "name": "get_rental_charges", "arguments": { "rental_id": "5d3b7a60-91c2-4f08-8a1e-0c4d2b6e7f19" } }It lists what it found, and does not decide for you:
Two rentals are running: quiet-river-7k2f ([hourly rate] an hour, [cost so far] so far) and
bold-heron-3a9c ([hourly rate] an hour, [cost so far] so far). A third, calm-otter-8d1e, is
stopped and bills for storage. Which should I stop?You say:
Stop quiet-river-7k2f. Keep the other one running, it's training.The agent calls stop_ for that one rental only. Without confirm, it gets a preview. It tells you that GPU billing ends and the GPUs are released, that the workspace stays on the host, and that storage is billed while the rental is stopped. You say yes, and it calls again with confirm: true:
{
"name": "stop_rental",
"arguments": { "rental_id": "5d3b7a60-91c2-4f08-8a1e-0c4d2b6e7f19", "confirm": true }
}It leaves bold-heron-3a9c and calm-otter-8d1e alone, because you didn't ask about them. It offers to delete calm-otter-8d1e if you no longer need its workspace. To delete, it would ask you to confirm the name, and pass it as confirm_.
Expose port 8000 of my rental
You say:
My app is listening on port 8000 in quiet-river-7k2f. Put it on the internet, but only for my office, 203.0.113.0/24.The agent checks the rental and whether exposure is on for you:
{ "name": "get_rental", "arguments": { "rental_id": "5d3b7a60-91c2-4f08-8a1e-0c4d2b6e7f19" } }{ "name": "get_rental_network", "arguments": { "rental_id": "5d3b7a60-91c2-4f08-8a1e-0c4d2b6e7f19" } }The rental is running, and inbound. is true. If it were false, the agent would tell you to ask support, and stop. The agent then asks, because exposing a port is a change to who can reach your machine:
I'll make a service for port 8000 of quiet-river-7k2f at a URL like https://quiet-river-7k2f-4x9a.ambi.run (Legion adds a short random ending), reachable only
from 203.0.113.0/24. Your app must listen on 0.0.0.0, not 127.0.0.1, and speak plain HTTP.
It should have its own sign-in: anyone in that range who finds the address can reach it.
Shall I do it?You say yes. The agent calls create_ with a fresh idempotency_ and confirm: true. This needs a Full access API key: with an Agent key the agent sends you to the app instead.
{
"name": "create_service",
"arguments": {
"idempotency_key": "0b8a3f6e-5c1d-4e27-8a9f-3d2c1b0a9e8f",
"confirm": true,
"body": {
"protocol": "http",
"target": { "mode": "rental", "rental_id": "5d3b7a60-91c2-4f08-8a1e-0c4d2b6e7f19", "port": 8000 },
"access": { "mode": "public", "sources": ["203.0.113.0/24"] }
}
}
}It calls get_ until its status is ready, and gives you the Service URL. If you had said "anyone", sources would be empty, and the agent would have said so in its question: an empty list means anyone on the internet.
To take it down, ask. The agent calls delete_ with the service's ID after you say yes, and the Service URL stops working. The rental keeps running.
Change a host's price, as a provider
This one needs a key made with Can manage hosts, created by an organization owner. You say:
Set my host amber-falcon to three dollars an hour per GPU.The agent reads the host, so it knows the current name and price:
{ "name": "get_host", "arguments": { "host_id": "8c0e2f4a-1b3d-4e5f-9a7b-6c5d4e3f2a1b" } }It calls the write tool without confirm, which changes nothing and returns the preview:
{
"name": "update_host_listing",
"arguments": {
"host_id": "8c0e2f4a-1b3d-4e5f-9a7b-6c5d4e3f2a1b",
"body": { "listed": true, "price_per_gpu_hour": { "amount_minor": 300, "currency": "USD" } }
}
}It shows you the preview, in dollars and in cents, and asks:
I'll change amber-falcon from [old price] to [new price] per GPU-hour (300 cents). Rentals
already running keep their price; new rentals pay the new one and earn you [earnings]
per GPU-hour. The host stays listed. Shall I do it?You say yes. The agent calls the tool again with confirm: true, the host's current name and the price in cents:
{
"name": "update_host_listing",
"arguments": {
"host_id": "8c0e2f4a-1b3d-4e5f-9a7b-6c5d4e3f2a1b",
"confirm": true,
"confirm_host_name": "amber-falcon",
"expected_listing_price_per_gpu_hour_minor": 300,
"body": { "listed": true, "price_per_gpu_hour": { "amount_minor": 300, "currency": "USD" } }
}
}If the cents did not match the body's price (say it sent 3 for 300), the server would refuse with price_ and change nothing. The same pattern covers rename_ and remove_; for a removal the agent first offers to stop new rentals instead, because removing cannot be undone.