API reference
Every operation of the Legion API you can call with an API key, and the public market API, by area.
Base URL https://api.legion.ambient.xyz/v1. The whole API as OpenAPI: openapi.json · openapi.yaml.
Offers
Search the market's GPU offers, read one host's offer, and the score formula.
- GET/v1/offersSearch GPU offersAPI keyPaginated
- GET/v1/offers/{host_id}Get one offer with its score breakdown and uptime historyAPI key
- GET/v1/offer-alertsList the caller's offer alertsAPI keyPaginated
- POST/v1/offer-alertsBe emailed once when a matching machine is availableAPI key
- GET/v1/offer-alerts/{alert_id}Get one offer alertAPI key
- PATCH/v1/offer-alerts/{alert_id}Rename, re-arm or change the expiry of an offer alertAPI key
- DELETE/v1/offer-alerts/{alert_id}Delete an offer alertAPI key
- GET/v1/score-formulaHow the Legion score is computedAPI key
Rentals
Rent GPUs, then list, stop, start and delete rentals, back them up and read their network.
- GET/v1/rentalsList the organization's rentalsAPI keyPaginated
- POST/v1/rentalsRent GPUs on a hostAPI keyIdempotent
- GET/v1/rentals/{rental_id}Get a rentalAPI key
- PATCH/v1/rentals/{rental_id}Change a rental's settingsAPI key
- DELETE/v1/rentals/{rental_id}Delete a rental and its workspaceAPI key
- GET/v1/rentals/{rental_id}/serveHow to reach the model a rental servesAPI key
- POST/v1/rentals/{rental_id}/serve/exposeCreate the rental's model service if it has noneAPI key
- GET/v1/rentals/{rental_id}/networkThe rental's effective network policy and whether its host applied itAPI key
- GET/v1/rentals/{rental_id}/hostThe host a rental runs on, its health and its GPUs' live telemetryAPI key
- GET/v1/rentals/{rental_id}/network/activityWhat the rental's network blocked or would have blocked in the last 24 hoursAPI key
- GET/v1/rentals/{rental_id}/logsRead a rental's logsAPI keyPaginated
- POST/v1/rentals/{rental_id}/stopStop a rentalAPI key
- POST/v1/rentals/{rental_id}/startRestart a stopped rentalAPI key
- GET/v1/rentals/{rental_id}/workspace-exportsList a rental's recent workspace exportsAPI key
- POST/v1/rentals/{rental_id}/workspace-exportsExport a stopped rental's workspaceAPI key
- GET/v1/rentals/{rental_id}/workspace-exports/{export_id}Get a workspace exportAPI key
- POST/v1/rentals/{rental_id}/workspace-exports/{export_id}/cancelCancel a pending workspace exportAPI key
- GET/v1/rentals/{rental_id}/workspace-exports/estimateWhat downloading a rental's workspace export will costAPI key
- POST/v1/rentals/{rental_id}/workspace-exports/{export_id}/download-linksMake a single-use download link for a ready workspace exportAPI keyIdempotent
- GET/v1/storage-policyHow long a stopped rental's files are kept, and what backups costAPI key
- GET/v1/rentals/{rental_id}/transferData this rental sent out through Legion's relays, and what it costAPI key
- GET/v1/transferThe organization's relay traffic this month, its free allowance and the rentals that used mostAPI key
- GET/v1/rentals/{rental_id}/backup-estimateWhat a backup of this rental would costAPI key
- GET/v1/rentals/{rental_id}/backupsA rental's backups, newest firstAPI keyPaginated
- POST/v1/rentals/{rental_id}/backupsBack up a stopped or failed rental's workspaceAPI keyIdempotent
- GET/v1/backupsThe organization's backups, newest firstAPI keyPaginated
- GET/v1/backups/{backup_id}Get a backupAPI key
- DELETE/v1/backups/{backup_id}Delete a ready backup earlyAPI key
- POST/v1/backups/{backup_id}/cancelCancel a queued or uploading backupAPI key
- POST/v1/backups/{backup_id}/download-linksMint a download link for a ready backupAPI keyIdempotent
Services
Public URLs for what you run on Legion, on a port of a rental or autoscaled on rented GPUs: create, change, pause and delete them, manage their keys, and read their replicas, usage and activity.
- GET/v1/servicesList the organization's servicesAPI keyPaginated
- POST/v1/servicesCreate a serviceAPI keyIdempotent
- GET/v1/services/defaultsThe defaults of a new serviceAPI key
- POST/v1/services/estimateEstimate what a service would costAPI key
- GET/v1/services/{service_id}Get a serviceAPI key
- PATCH/v1/services/{service_id}Change a service's model, hardware, scaling or budget, or switch autoscaling on or offAPI key
- DELETE/v1/services/{service_id}Delete a serviceAPI key
- POST/v1/services/{service_id}/pausePause a serviceAPI key
- POST/v1/services/{service_id}/resumeResume a paused serviceAPI key
- GET/v1/services/{service_id}/keysList a service's keysAPI keyPaginated
- POST/v1/services/{service_id}/keysCreate a service keyAPI keyIdempotent
- DELETE/v1/services/{service_id}/keys/{key_id}Revoke a service keyAPI key
- POST/v1/services/{service_id}/keys/{key_id}/rotateRotate a service keyAPI key
- GET/v1/services/{service_id}/replicasList a service's replicasAPI keyPaginated
- GET/v1/services/{service_id}/usageA service's metrics and costAPI key
- GET/v1/services/{service_id}/metricsA service's inference metricsAPI key
- GET/v1/services/{service_id}/eventsA service's activityAPI keyPaginated
- GET/v1/services/{service_id}/logsRead a service's logs, every replicaAPI keyPaginated
Images
Check a container image in its registry before you rent with it.
- GET/v1/catalog/settingsWhich catalog entries Legion has hidden or disabled, and whether custom images are allowedAPI key
- GET/v1/catalogList Legion's starter images and premade models, and which a host can runAPI key
- POST/v1/images/inspectInspect a container image before renting itAPI key
- GET/v1/registry-sign-insThe organization's registry sign-insAPI key
- PUT/v1/registry-sign-ins/{registry}Save the organization's sign-in for a registryAPI key
- DELETE/v1/registry-sign-ins/{registry}Remove the organization's sign-in for a registryAPI key
- GET/v1/registry-credentialsThe organization's registry credentialsAPI key
- POST/v1/registry-credentialsSave a registry credentialAPI key
- POST/v1/registry-credentials/detectSplit an image reference into registry host and path prefixAPI key
- GET/v1/registry-credentials/{credential_id}One registry credentialAPI key
- PATCH/v1/registry-credentials/{credential_id}Rename a registry credential or replace its secretAPI key
- DELETE/v1/registry-credentials/{credential_id}Remove a registry credentialAPI key
Billing
Your organization's balance, ledger, charges, top-ups, auto top-up and promo codes, and a provider's earnings and payouts.
- GET/v1/rentals/{rental_id}/chargesGet what a rental has costAPI key
- GET/v1/billing/accountGet the organization's balanceAPI key
- GET/v1/billing/ledgerList the organization's ledger entriesAPI keyPaginated
- GET/v1/billing/activityList what happened to the organization's balance or earningsAPI keyPaginated
- GET/v1/billing/chargesList what the organization's rentals have costAPI keyPaginated
- GET/v1/billing/earningsGet the organization's provider earningsAPI key
- GET/v1/billing/earnings/rentals/{rental_id}Get what a rental on one of the organization's hosts has earnedAPI key
- GET/v1/provider/earnings/overviewThe organization's earnings over a period, with the previous periodAPI key
- GET/v1/provider/earnings/seriesThe organization's earnings over timeAPI key
- GET/v1/provider/earnings/breakdownThe organization's earnings by one dimensionAPI key
- GET/v1/provider/earnings/hostsWhat each of the organization's hosts earned and how it performedAPI key
- GET/v1/provider/earnings/hosts/{host_id}One host's earnings, utilization, uptime and price against the marketAPI key
- GET/v1/provider/earnings/rentalsThe rentals on the organization's hosts that were billed in a periodAPI key
- GET/v1/provider/earnings/attentionHosts that are earning less than they could, with what to doAPI key
- GET/v1/provider/earnings/payoutsWhat is payable, when the next payout runs and the history of payoutsAPI key
- GET/v1/renter/spend/overviewThe organization's spend over a period, with the previous periodAPI key
- GET/v1/renter/spend/seriesThe organization's spend over timeAPI key
- GET/v1/renter/spend/breakdownThe organization's spend by one dimensionAPI key
- GET/v1/renter/spend/rentalsThe organization's rentals that were charged in a periodAPI key
- GET/v1/billing/payoutsGet the organization's payout setupAPI key
- GET/v1/billing/top-upsList the organization's top-upsAPI keyPaginated
- POST/v1/billing/top-upsTop up the organization's balanceAPI keyIdempotent
- GET/v1/billing/auto-top-upSee the organization's auto top-upAPI key
- PUT/v1/billing/auto-top-upTurn auto top-up on or off and set its amountsAPI keyIdempotent
- POST/v1/billing/auto-top-up/cardSave or replace the card auto top-up chargesAPI key
- DELETE/v1/billing/auto-top-up/cardRemove the saved card and turn auto top-up offAPI key
- GET/v1/billing/credit-refund-quoteSee how much unused credit can be refunded, and the fee keptAPI key
- POST/v1/billing/credit-refundsRefund unused credit to the cards and bank accounts it came fromAPI keyIdempotent
- POST/v1/billing/promo-codes/previewCheck what a promo code gives the organizationAPI key
- POST/v1/billing/promo-codes/redeemRedeem a promo codeAPI keyIdempotent
- GET/v1/billing/promo-redemptionsList the organization's promo code redemptionsAPI keyPaginated
- GET/v1/billing/promo-creditGet the organization's promo credit and discountsAPI key
Network
Your organization's outbound allow-list, and requests to add a site to it.
- GET/v1/network/egress-allowlistThe organization's outbound allow-listAPI key
- PUT/v1/network/egress-modeHold the organization's new rentals to the allow-listAPI key
- GET/v1/egress-requestsThe organization's egress requestsAPI keyPaginated
- POST/v1/egress-requestsAsk for a destination to be added to the allow-listAPI keyIdempotent
- POST/v1/egress-requests/{egress_request_id}/withdrawWithdraw a pending egress requestAPI key
Hosts
The hosts you provide: enrollment tokens, listings, names, benchmarks, network and removal.
- GET/v1/enrollment-tokensList pending enrollment tokensAPI keyPaginated
- POST/v1/enrollment-tokensCreate a host enrollment tokenAPI key
- DELETE/v1/enrollment-tokens/{enrollment_token_id}Revoke an enrollment tokenAPI key
- GET/v1/hostsList the organization's hostsAPI keyPaginated
- GET/v1/hosts/{host_id}Get a hostAPI key
- POST/v1/hosts/{host_id}/removeRemove a hostAPI key
- GET/v1/maintenance-windowsThe organization's maintenance windowsAPI keyPaginated
- POST/v1/maintenance-windowsSchedule maintenance on one or many hostsAPI keyIdempotent
- GET/v1/maintenance-windows/previewWhat scheduling maintenance would doAPI key
- POST/v1/maintenance-windows/rescheduleMove or change scheduled maintenance windowsAPI key
- POST/v1/maintenance-windows/cancelCancel scheduled maintenance windowsAPI key
- POST/v1/maintenance-windows/endEnd active maintenance windows now ("done with maintenance")API key
- GET/v1/hosts/{host_id}/removal-previewPreview what is on a host before removing itAPI key
- PUT/v1/hosts/{host_id}/nameRename a hostAPI key
- PUT/v1/hosts/{host_id}/listingSet a host's price and availabilityAPI key
- GET/v1/hosts/{host_id}/benchmarksA host's benchmark runs, newest firstAPI key
- GET/v1/hosts/{host_id}/first-benchmarkProgress of a host's first benchmarkAPI key
- POST/v1/hosts/{host_id}/benchmark-requestAsk your host to benchmark againAPI key
- POST/v1/hosts/{host_id}/start-hold/releaseTake your host off its start-failure pauseAPI key
- GET/v1/hosts/{host_id}/gpu-benchmarksA host's GPU benchmark runs, newest firstAPI key
- GET/v1/hosts/{host_id}/listing-historyA host's listing price history, newest firstAPI keyPaginated
- GET/v1/hosts/{host_id}/price-recommendationWhat Legion recommends the host charge per GPU-hourAPI key
- GET/v1/hosts/{host_id}/networkA host's network state and the abuse flags raised on its rentalsAPI key
- PUT/v1/hosts/{host_id}/networkSet the destinations blocked for rentals on a hostAPI key
Identity and keys
Who a key acts as, API keys, saved SSH public keys and your organization's invitations.
- GET/v1/meGet the callerAPI key
- GET/v1/api-keysList the caller's API keysAPI keyPaginated
- POST/v1/api-keysCreate an API keyAPI key
- DELETE/v1/api-keys/{api_key_id}Revoke an API keyAPI key
- GET/v1/ssh-keysList the caller's saved SSH public keysAPI key
- POST/v1/ssh-keysSave an SSH public keyAPI key
- DELETE/v1/ssh-keys/{ssh_key_id}Delete a saved SSH public keyAPI key
- GET/v1/invitationsList pending invitationsAPI keyPaginated
- POST/v1/invitationsInvite a person to the organizationAPI key
- DELETE/v1/invitations/{invitation_id}Revoke a pending invitationAPI key
- POST/v1/invitations/{invitation_id}/resendEmail an invitation againAPI key
- GET/v1/membersList the organization's membersAPI keyPaginated
Notifications
What the bell shows, marking it read, and which events your organization is emailed about and to whom.
- GET/v1/notificationsList the organization's notificationsAPI keyPaginated
- POST/v1/notifications/readMark every notification readAPI key
- POST/v1/notifications/{notification_id}/readMark a notification readAPI key
- GET/v1/notification-settingsWhich notifications are emailed, and to whomAPI key
- PUT/v1/notification-settings/{kind}Change whether a notification is emailed, and to whomAPI key
Legal
The current versions of Legion's legal documents.
Public market
An anonymous, cached summary of what can be rented now. No key needed.