Skip to content

Services

A service is a public URL for something you run on Legion. Point it at a port on one of your rentals, or let Legion run your model on rented GPUs and scale it with traffic, down to zero when idle. What it is, the two modes, and when to use each.

On this page

A service is a public URL for something you run on Legion. Point it at a port on one of your rentals, or let Legion run your model on rented GPUs and scale it with traffic, down to zero when idle.

Every service has a URL, an access setting and something that answers:

  • The Service URL is https://<name>-<suffix>.ambi.run: the name you pick, then a short random ending Legion adds. The name is unique within your organization, so two organizations can use the same name, and the ending keeps URLs from being guessable. The URL never changes, not even when what is behind it does. It is shown on the service and in the create response.

  • The access is Public (anyone with the URL) or API key required (callers must send a service key). Either can also be limited to a list of IP addresses.

  • What answers depends on the service's mode, below.

The two modes

The two modes
ModeWhat answersReplicasHow it starts
On a rentalA port on one rental that you manage: your machine1Expose a port, or rent a premade model and its service is made for you
AutoscaledA model or image on GPUs that Legion rents for the service0 to NCreate a service

An autoscaled service is serverless: it scales to zero when idle. Each GPU machine that runs it is a replica. A replica is an ordinary rental of your organization that only Legion starts and stops. Vast and RunPod call these workers.

Whether a service serves a model is shown by its model, not by its mode: a service on a rental can serve a premade model, and an autoscaled one can serve your own image.

Every service has the same page, the same keys and the same activity feed, whatever its mode. The Services list under Rent shows them all, and a rental's Services tab shows the ones on that rental.

What you get

  • A URL that does not change. Replicas come and go behind it.

  • Access you control. Service keys work for one service only, are shown once, expire, rotate and revoke within seconds. A key is checked by Legion and never reaches your machine. See Keys and security.

  • Autoscaling, when you want it. Legion starts a replica when requests pile up and stops one when they stop, between the minimum and the maximum you choose. It can scale to zero, so an idle service costs nothing. See Scaling and cold starts.

  • Streaming. Responses stream byte for byte, so server-sent events from a chat model reach your client as they are made.

  • A spend cap. An autoscaled service needs a monthly cap, and a service on a rental can have one. When this month's spend reaches it, the service stops until you raise the cap or the month ends. See Service billing.

  • Metrics, usage and history. The service's page shows requests, errors, latency and tokens (Service metrics), spend, each replica, and a feed of what the autoscaler and your team did.

Which one to use

Which one to use
ComparedOn a rentalAutoscaled
What serves requestsThe one rental you choseReplicas that Legion rents for the service
Who starts and stops itYou, in the rental's pageLegion
Access to the machineSSH, files and the terminal, as for any rentalNone: replicas are all the same
When nothing is happeningIt bills until you stop the rentalIt can scale to zero and bill nothing
Spend capOptionalRequired
Best forSomething you develop, try or share with a few callersAn API your application or your customers call, with traffic that varies

To try a model for an afternoon, rent a premade model: it gets a service with one key and works at once. See Images and premade models. Use autoscaling when other software depends on the service and you don't want to run the machines.

From one rental to autoscaling

A service on a rental can become an autoscaled one, and back, without changing its URL or its keys.

To turn autoscaling on, open the service and choose Turn on autoscaling (or run legion services autoscale on chat --monthly-cap 300). It opens the Hardware and Scaling and budget steps of the create form, filled in from your rental: its GPU type as the starting allow-list, a minimum of 1, a maximum of 2, and a spend cap you must set. On the last step choose how the rental moves:

  • Keep this rental as the first replica (the default; --keep-rental). The rental becomes a replica that Legion manages, so you stop managing it yourself.

  • Start fresh replicas and stop this rental when they are ready (--replace). New replicas start on other hosts first, and your rental stops after they are ready, so requests are not dropped.

To go back, choose Turn off autoscaling, or run legion services autoscale off chat --keep-replica NAME: pick one ready replica to keep as your single rental, and the others drain and stop.

Older served rentals and ports. A rental that served a model before services existed keeps its direct address and its key working unchanged, and nothing restarts. Its service's Keys tab lists that key as Direct key (legacy) with the direct address and a Revoke action that closes direct access. An exposed port that existed before services keeps its URL, and is now a service on that rental with that URL's name. New served rentals have no separate direct address.

What a service can run

A service's protocol is one of:

  • openai: an OpenAI-compatible API under /v1/, such as a chat or embeddings model. Legion checks the model and answers readiness for it, and the service's page shows a quickstart. Use the OpenAI SDKs with the Service URL.

  • http: any HTTP service, on the port you give.

An autoscaled service runs either a premade model from Legion's catalog or, when your organization may use its own images, your own image with its port, protocol and model name. WebSocket services such as ComfyUI are not autoscaled yet.

What a service does not do

  • No queue of jobs. Requests are synchronous: you send one and wait for the answer. There is no run-and-poll queue, no webhooks and no stored results. A request that arrives when every replica is busy waits briefly in a bounded queue, then is refused. See Limits and status codes.

  • No lasting shell on a replica. There is no SSH on replicas, and no web terminal unless you allow it in the service's settings (see Web terminal on replicas). Replicas are all the same, started from the image, and what you change inside one is lost when it is replaced or scaled down. (A rental you manage keeps its SSH.)

  • No downtime when you change it. Scaling, the price ceiling and the spend cap apply to the next scaling decision. A change of model, image or hardware replaces replicas one at a time, with one surge replica that counts against your maximum and your spend cap, so requests are not dropped.

  • No promise about who runs the GPUs. A rental or a replica runs on a machine owned by a Legion provider, and a host can see the requests it serves. Read What a host can see before you send private data.

Where to go next

  1. Expose a port of a rental, or create an autoscaled service, in the app, with the CLI or from an agent.

  2. Call it with curl or an OpenAI SDK.

  3. Tune scaling and read what it costs.

  4. Learn the limits and the status codes your callers can meet.