Manage private inference engines that run workers on your hardware. Use these endpoints to list engines, inspect status, and perform safe restarts without dropping in-flight tasks.
Requires API key scopes engines:read (list/get, release channels) and engines:write (rename, visibility, transfer, capacity, drain, update, stop, restart). Enroll is public; its token is the credential.
→ Workers · Installing the engine · Configuration
Register engine
POST /engines/register
Called by the inferencesh-engine binary on startup (after registration). Creates a new engine record for your workspace or re-registers an existing one, allocates workers from detected hardware, and returns worker IDs the engine uses for task routing.
Requires engines:write. You normally do not call this manually — install the engine and run engine setup (Linux) or engine serve (macOS) instead.
Request
| Field | Type | Description |
|---|---|---|
local_engine_state | object | Engine ID, name, config, and public key from local state |
api_url | string | API base URL the engine connects to |
system_info | object | Host OS, architecture, and detected hardware |
worker_config | object | Worker allocation preferences from engine.yml |
Response
| Field | Type | Description |
|---|---|---|
engine_id | string | Assigned or confirmed engine ID |
workers | array | Allocated workers with id, gpus, cpus, and rams |
On first run, the API creates a new engine with status pending. On subsequent starts, the engine sends its saved ID; the API updates hardware info and worker allocation, sets status to pending, and clears any prior stop reason (starting the process is an explicit start, including after you Stop an engine in the workspace).
Register does not set running. The engine opens its WebSocket after register; that connection moves status to running. Between register and connect you may briefly see pending in list or get responses — nothing in the API waits on running during that gap.
After connect, the engine maintains the WebSocket for task dispatch, drain/update signals, and heartbeats. The API treats that connection as the source of truth for whether the engine is online. See Installing the engine for setup steps.
List engines
GET /engines or POST /engines/list
Cursor-paginated list of engines for your workspace. Requires engines:read. limit defaults to 10 and is capped at 200. A sort or filters entry that names a field engines do not have returns 400 invalid_request (Invalid sort or filter field).
1curl -X POST https://api.inference.sh/engines/list \2 -H "Authorization: Bearer inf_your_key" \3 -H "Content-Type: application/json" \4 -d '{"limit": 20}'Get engine
GET /engines/{id}
Returns an engine DTO. List responses (POST /engines/list) use the same shape per item.
| Field | Type | Description |
|---|---|---|
id | string | Engine ID |
name | string | Display name |
status | string | Lifecycle state — see table below |
engine_version | string | Installed inferencesh-engine binary version (e.g. v1.10.15). Set from engine telemetry heartbeats; empty until the first telemetry sync after connect. Also shown in the web app's Engines detail view |
engine_pin | string | Release the engine is held on after an update to canary or a specific version (for example canary or v1.9.3). Empty means it follows stable. Set from engine telemetry |
api_url | string | API base URL the engine connects to |
workers | array | Worker DTOs with status, GPU/CPU allocation, and current task_id when busy |
system_info | object | Optional host telemetry (OS, GPUs, RAM). Also includes engine_version, mirrored from the top-level field, and on Linux host_cpu |
instance | object | Cloud instance metadata when provisioned through inference.sh (includes rental_type: on_demand or spot) — see Cloud instance |
capabilities | string[] | Optional. Capabilities the engine last reported in telemetry — see Engine capabilities |
capacity | object | Optional. What the engine offers and has given out — see Engine capacity. Omitted when the engine does not report it |
capacity_policy | object | Optional. What you set with Set capacity policy. Omitted when you have not set one |
| Status | Meaning |
|---|---|
running | Connected over WebSocket and accepting tasks |
pending | Register completed; WebSocket not connected yet |
draining | Connected; finishing in-flight tasks and rejecting new work |
restarting | Connected; draining before a process restart (for example after Update) |
disconnected | WebSocket closed; reversible when the engine reconnects |
stopping | Shutting down |
stopped | Fully stopped |
While connected, heartbeats report the finer states above (running, draining, or restarting). When the WebSocket drops, status moves to disconnected even if the host process is still running. A new connection moves the engine back to running from disconnected, pending, or restarting, and can revive a stopped engine after a disconnect-only stop. A Stop you issued or a completed drain is final for reconnect alone — run the engine again (engine serve) so register clears the stop and sets pending, then connect sets running.
Spot cloud engines: when the cloud provider reclaims a spot instance (instance.rental_type is spot), the engine is finalized as stopped with stop_reason: "preempted" and does not come back on reconnect. Unused prepaid time is refunded as for a stop. Provision a new cloud engine (or switch to on-demand) to replace the capacity.
If an engine stays disconnected for about ten minutes, the API finalizes it as stopped: workers are marked inactive, in-flight tasks fail, and cloud instances may be torn down. Brief outages (for example during an API deployment) normally recover when the engine reconnects before that window.
While the engine is still in that reconnect grace (disconnected, not yet finalized), worker liveness follows the engine, not a separate wall-clock on each worker heartbeat. A WebSocket drop does not, by itself, retire workers or fail their in-flight tasks — work can keep running on the host and resume dispatch when the connection returns. Workers are retired when the engine is finalized, when you stop or delete the engine, or when the engine stays connected but has not reported a given worker in its heartbeats for about 90 seconds (for example, a crashed worker slot). API downtime does not count against workers either: engine heartbeats stop being recorded at the same time, so workers are not marked gone during a platform restart.
If the platform ends a task while your engine could not be reached (for example a Dispatched task that fails after about 30 seconds without a connection), the task row is already Failed or Cancelled but a worker may still be running that work on the host. On the next engine telemetry report after reconnect (on connect and about every 30 seconds while connected), the API compares what each worker reports against the task record and sends a force cancel to any worker still running a task the platform no longer owns on that engine. That stops stray side effects without re-queueing the same run on another engine. Completed tasks are never treated as stale — a worker may still be uploading results after the compute phase finishes.
JavaScript SDK: EngineStatusDisconnected, EngineStatusRestarting, and other status constants ship in @inferencesh/sdk ≥ v0.6.12. EngineDTO includes engine_version and engine_pin (engine_pin from v0.29.0), matching the REST API response. Python SDK: EngineDTO in inferencesh.types includes the same fields (engine_pin from inferencesh v0.31.0); use it when calling GET /engines/{id} directly.
1curl "https://api.inference.sh/engines/eng_abc123" \2 -H "Authorization: Bearer inf_your_key"Engine capabilities
Engines report optional capabilities beyond the base task-running contract. The scheduler only assigns a task to an engine that satisfies every capability the task requires.
| Capability | Meaning |
|---|---|
egress_gateway | Task sandboxes reach the internet only through the engine's egress gateway. The gateway puts a bound secret on requests to its allowed hosts, so the secret never enters the sandbox, and it reports each task's byte totals on the task's egress field. Any run that declares secrets: or credentials: (plus runs with bound secrets or an upstream proxy) needs an engine with this capability. → Task egress |
egress_pending | The gateway starts a task or sandbox without login values and fetches each one from the API the first time a request needs it. → Egress grants |
egress_grants | The gateway keeps a fetched login value only as long as the API says, refuses a declined login with the API's reason, and drops a login at once when the API revokes it. Tasks get logins fetched on first use only on engines with it |
egress_decide | The gateway holds a request while the owner is asked to allow a login (at most 3 minutes) and wakes it as soon as they answer |
egress_forms | The gateway puts a bound value in a request body, and signs a token with it (jwt). Tasks that may get a value in these forms go only to engines with it |
egress_h2 | The gateway speaks HTTP/2 with the box and with the bound host, so gRPC clients get their bound value. Tasks given a key marked transport: h2 need it |
egress_host_suffix | The gateway reads a bound host that starts with a dot (.example.com) as every host under that domain. Values bound that way are sent only to engines with it |
egress_host_any | Required together with egress_gateway on every run that receives secrets or credentials. The gateway resolves keys bound to no fixed host list (plain secrets:, and the keys of a credential that has no hosts), including per-host approval when needed. Self-hosted engines that do not report egress_host_any cannot serve those runs. |
sandboxes | The engine runs managed sandboxes |
capacity | The engine reports capacity |
sized_sandboxes | Sandboxes run without holding a worker; the API places them by size against the engine's capacity |
sized_workers | The engine makes a CPU app worker sized for each run; the API places CPU app runs by size against the engine's capacity instead of fixed CPU slots |
JavaScript SDK: EngineCapabilityEgressGateway (@inferencesh/sdk ≥ v0.29.0), EngineCapabilitySandboxes (v0.38.1), EngineCapabilityCapacity (v0.38.2), EngineCapabilityEgressPending (v0.38.6), EngineCapabilityEgressGrants (v0.38.9), EngineCapabilityEgressDecide (v0.38.13), EngineCapabilitySizedSandboxes and EngineCapabilitySizedWorkers (v0.38.15), EngineCapabilityEgressForms, EngineCapabilityEgressH2 and EngineCapabilityEgressHostSuffix (v0.41.6), EngineCapabilityEgressHostAny (v0.45.0). Python SDK: EngineCapability in inferencesh.types; CAPACITY from inferencesh v0.38.0, EGRESS_PENDING from v0.38.5, EGRESS_GRANTS from v0.38.7, EGRESS_DECIDE from v0.38.10, EGRESS_FORMS, EGRESS_H2 and EGRESS_HOST_SUFFIX from v0.42.0.
Engine capacity
An engine with the capacity capability reports what it offers and what it has given out. The API keeps the latest report on the engine. An engine that stops reporting it does not clear the stored value.
| Field | Type | Description |
|---|---|---|
cpus | integer | Logical CPUs (hardware threads) the engine may use |
cores | integer | Physical cores |
memory_bytes | integer | Memory |
disk_bytes, disk_free_bytes | integer | Size and free space of the volume the engine's data is on |
gpus | array | Optional. One {id, vram_bytes} per GPU |
reserve | object | CPU and memory kept back for the host |
allocatable | object | CPU and memory left to give out |
committed | object | CPU and memory promised: app workers' quotas and sandbox sizes |
committed_apps | object | The app workers' part of committed |
used | object | CPU and memory in use now |
Each object has cpus (a number; 1.5 is one and a half CPUs) and memory_bytes.
JavaScript SDK: EngineCapacity, CapacityAmount and CapacityGPU (@inferencesh/sdk ≥ v0.38.2). Python SDK: the same names (inferencesh ≥ v0.38.0).
Host CPU settings
On Linux, system_info.host_cpu reports how the host runs its CPUs, read from /sys, plus a CPU benchmark the engine runs at startup. It is omitted on other systems and from engines that predate it. Remotes do not send it.
| Field | Type | Description |
|---|---|---|
governor, driver | string | cpu0's cpufreq scaling_governor and scaling_driver |
boost | boolean | Turbo or boost on or off. Omitted when the host does not say |
cur_mhz | number | Mean current frequency across CPUs |
max_mhz | number | cpu0's hardware maximum frequency |
smt | boolean | Simultaneous multithreading on or off. Omitted when unknown |
threads_per_core | integer | Threads per core |
hugepages_2m_total, hugepages_2m_free | integer | Reserved and free 2 MiB huge pages |
thp | string | Transparent huge page mode: always, madvise or never |
kvm | boolean | /dev/kvm is present |
cpu_score | object | The startup benchmark: single_ops_per_sec, all_ops_per_sec and threads. Omitted until it has run |
The system_info in task telemetry is a smaller shape without host_cpu. Types: HostCPU and CPUScore (@inferencesh/sdk ≥ v0.39.1, inferencesh ≥ v0.39.1).
Cloud instance
instance is an InstanceDTO: provider, region, instance type, SSH details, ip, status, hourly_price (cents per hour), rental_type, and the provider's configuration, auto_delete, alert and volume_mount. It never includes the launch script or its environment, since the script holds the engine's enrollment token. The Python InstanceDTO type drops those fields from inferencesh v0.41.1.
status | Meaning |
|---|---|
creating, pending_provider, pending | Being provisioned |
active | Running |
error | The provider reported an error |
deleting, deleted | Being removed, removed |
GET /engines/{id}/instance/status returns the same InstanceDTO. Requires engines:read; an engine with no cloud instance returns 404. A caller who may write the engine gets a fresh read from the provider; everyone else gets the last synced copy.
Match engines to resource requirements
POST /engines/resources
Check which workers can satisfy a given resource profile before you run an app with infra: "private" or choose between cloud and private capacity. The web app's run form uses this endpoint to show available private workers and cloud price ranges.
Authentication is optional (guest workspaces get public cloud availability only). With an API key, your workspace's private workers are included in the response.
Request
| Field | Type | Required | Description |
|---|---|---|---|
resources | object | Yes | Resource requirements to match |
resources.gpu.count | integer | No | GPUs required (0 for CPU-only) |
resources.gpu.vram | integer | No | Minimum VRAM per GPU (bytes) |
resources.gpu.type | string | No | any, none, nvidia, amd, intel, or apple |
resources.ram | integer | No | Minimum system RAM (bytes) |
Pass the resources block from the app version you plan to run (see App configuration). Values are in bytes — the same internal representation stored on deployed app versions after CLI deploy.
1curl -X POST https://api.inference.sh/engines/resources \2 -H "Authorization: Bearer inf_your_key" \3 -H "Content-Type: application/json" \4 -d '{5 "resources": {6 "gpu": { "count": 1, "vram": 24000000000, "type": "nvidia" },7 "ram": 160000000008 }9 }'Response
| Field | Type | Description |
|---|---|---|
private.workers | array | Matching workers in your workspace |
cloud.can_run | boolean | Whether shared cloud workers can satisfy the profile |
cloud.min_price | integer | Lowest matching cloud worker price (cents per hour) |
cloud.max_price | integer | Highest matching cloud worker price (cents per hour) |
error | string | Present when matching failed |
Each worker summary includes id, engine_id, engine_name, status, GPU/CPU/RAM details, and the current task_id when busy.
Use this before POST /run when you need to confirm capacity or pick specific workers — see Using private workers.
→ Instance types · Workers concept
List engine instance types
GET /engines/types
Authenticated catalog for provisioning cloud engines in the workspace. Requires engines:read.
Returns one row per GPU type, GPU count, and rental type (on_demand or spot): the cheapest available option for that tuple, or for on-demand the cheapest unavailable row when nothing is in stock. Spot offers are omitted when no region has spot stock.
Each row is an instance type object with rental_type, region, and hourly_price set for that offer (the raw public catalog leaves rental_type empty). Spot row IDs are suffixed with .spot.
Each offer also includes an options array: every in-stock cloud provider for that GPU type, GPU count, and rental type. Options are sorted by cheapest hourly_price first; the first entry always matches the top-level offer (cloud, shade_instance_type, region, and hourly_price). Providers with no in-stock regions for that rental type are omitted.
Field (on each options[] item) | Description |
|---|---|
cloud | Provider key |
cloud_logo_url | Provider logo URL (same pattern as the public catalog) |
shade_instance_type | Shadeform catalog name to pass when launching |
cloud_instance_type | Provider-specific SKU |
hourly_price | Cheapest in-stock region, in cents per hour |
configuration | GPU and machine specs when present |
regions | In-stock regions for this provider, each with region and hourly_price (cents). Sorted cheapest first. Spot prices can differ by region; on-demand regions share the on-demand price |
Use the parent row's rental_type when launching. Pick cloud, shade_instance_type, and region from whichever options[] entry the user selects (not only the top-level offer fields). In the web app, the cloud engine confirm step exposes the same choice as a provider list and region selector — see Provision a cloud engine.
1curl "https://api.inference.sh/engines/types" \2 -H "Authorization: Bearer inf_your_key"Example fragment (one on-demand H100 offer with two providers):
1{2 "id": "runpod.NVIDIA H100 80GB HBM3",3 "cloud": "runpod",4 "region": "eu-north-1",5 "shade_instance_type": "NVIDIA H100 80GB HBM3",6 "rental_type": "on_demand",7 "hourly_price": 250,8 "options": [9 {10 "cloud": "runpod",11 "shade_instance_type": "NVIDIA H100 80GB HBM3",12 "hourly_price": 250,13 "regions": [{ "region": "eu-north-1", "hourly_price": 250 }]14 },15 {16 "cloud": "lambdalabs",17 "shade_instance_type": "gpu-h100-sxm-80gb",18 "hourly_price": 300,19 "regions": [20 { "region": "us-east-1", "hourly_price": 300 },21 { "region": "us-west-2", "hourly_price": 300 }22 ]23 }24 ]25}→ Instance types API for the full public GET /instances/types catalog and filters.
Create cloud engine
POST /engines
Provisions a new cloud engine on Shadeform. Requires engines:write and the workspace capability rent_engines, which only owners and admins hold (see Workspace settings view). A member without it gets 403 team_role_required, with meta.capability set to rent_engines, before anything is charged. The rental starts when the API receives the request and runs until end_time, which is also the cloud instance auto-delete threshold. Your workspace balance is debited in microcents for that span (from now through end_time) using the server-quoted hourly rate — the hourly_price field on instance_type is ignored.
end_time must be at least 1 hour and at most 30 days ahead of the request. The API allows about one minute of slack on the minimum so a client-computed end_time is not rejected by network latency. Requests outside that window return 400 with code invalid_request.
There is no start_time field — billing always begins at request arrival. When you expose a duration picker in a UI, compute end_time at submit from the user's chosen span (not when they opened the form) so the prepaid window matches what they selected. The inference.sh workspace does this for cloud engine launch.
Request
| Field | Type | Required | Description |
|---|---|---|---|
name | string | Yes | Engine display name |
end_time | string (RFC3339) | Yes | When the rental ends and the cloud instance auto-deletes |
instance_type | object | Yes | Launch target from a row returned by GET /engines/types |
instance_type.cloud | string | Yes | Provider key from the chosen options[] entry (or the top-level offer when you use the default) |
instance_type.region | string | Yes | Region from that option's regions list |
instance_type.shade_instance_type | string | Yes | shade_instance_type from the same options[] entry |
instance_type.rental_type | string | No | on_demand (default) or spot |
instance_type.hourly_price | integer | No | Ignored; pricing comes from the live Shadeform catalog |
1curl -X POST https://api.inference.sh/engines \2 -H "Authorization: Bearer inf_your_key" \3 -H "Content-Type: application/json" \4 -d '{5 "name": "h100-spot-1",6 "end_time": "2026-10-01T20:00:00Z",7 "instance_type": {8 "cloud": "runpod",9 "region": "us-east-1",10 "shade_instance_type": "NVIDIA H100 80GB HBM3",11 "rental_type": "spot"12 }13 }'The response is the created engine record (including instance with rental_type and quoted hourly_price). The engine boots via a launch script and moves to running after register and WebSocket connect, the same lifecycle as a self-hosted engine from that point.
The launch script does not carry the engine's API key. The cloud provider keeps the script and reruns it at every boot, and anyone who can read the instance can read it, so it holds a one-time enrollment token (infen-…) instead. On first boot the script trades the token for the engine's identity with POST /engines/enroll, and unattended setup registers the engine and runs it as the inferencesh system user. Later boots skip enroll.
Spot instances cost less but can be reclaimed by the provider at any time; see Get engine for behavior when that happens.
Errors and billing
If Shadeform cannot quote the instance (for example the offer is unavailable), the request fails before your balance is debited. Failures other than an invalid end_time return 500 internal_error with a generic message.
After the reservation debit succeeds, the API provisions the cloud instance and creates the engine record. If any later launch step fails, the request returns an error and no engine is left in your workspace — the API deletes the engine row if one was created, reverses the reservation debit, removes any engine API key from the attempt, and tears down any cloud instance that was started. The unused-time credit from Stop only applies when a cloud engine finishes normally.
Check your workspace billing history if a launch failed but you expected a charge or refund line item.
Balance charges: Launch, extend, and stop refunds all move workspace balance in microcents (see Billing API — Money units). Catalog and instance hourly_price values are cents per hour; runtime cost prorates by elapsed seconds at that rate (for example, three hours at 138 cents/hour is 414 cents of usage, stored as microcents on the balance). Each extend call debits separately; when you stop a cloud engine early, the API credits unused prepaid time (launch plus extensions) minus elapsed usage since the engine was created. In billing history, look for references such as cloud_engine:<name> (launch debit), cloud_engine_extend:<engine id> (extension debits), and engine:<engine id> stop refund (early-stop credit).
Enroll engine
POST /engines/enroll
Trades a one-time enrollment token for the engine's identity: the API pins the engine's signing key on it. The route is public (no Authorization header); the token is the credential. It is rate-limited to 20 requests per hour per IP. The cloud launch script calls it on first boot, and engine setup calls it on a private host.
Request
| Field | Type | Required | Description |
|---|---|---|---|
token | string | Yes | Enrollment token (infen-…) from the launch script or add engine |
signing_public_key | string | No | The engine's Ed25519 public key, base64url without padding. Engines from before engine identities leave it out and get an API key instead |
1curl -X POST https://api.inference.sh/engines/enroll \2 -H "Content-Type: application/json" \3 -d '{"token":"infen-your-one-time-token","signing_public_key":"<base64url key>"}'Response
| Field | Type | Description |
|---|---|---|
engine_id | string | The engine the token enrolled |
name | string | The engine's name. An engine no one named (engine- plus the first 8 characters of its id) gets an adjective-animal name here; a name you gave it stays |
api_key | string | Only without signing_public_key: the engine key's secret, returned once (Cache-Control: no-store). Enroll reissues it, so any earlier secret for that key stops working |
Each token works once. It is valid until the engine's end_time or 24 hours after the engine was created, whichever is sooner. Tokens minted with the earlier infse- prefix still enroll until they expire; lookup is by hash, not prefix. Unknown, expired and already-used tokens all return 401 unauthorized with the same message. Malformed JSON returns 400 invalid_request.
List engine release channels
GET /engines/releases
Returns the head of each engine release channel. Requires engines:read. The API caches the answer for a minute.
| Field | Type | Description |
|---|---|---|
stable | object | null | Head of the stable channel |
canary | object | null | Head of the canary channel; null when no canary build is published |
Each channel object has version (for example v1.21.6) and release_date.
1curl "https://api.inference.sh/engines/releases" \2 -H "Authorization: Bearer inf_your_key"Drain engine
POST /engines/{id}/drain
Gracefully prepare an engine for shutdown:
- Marks the engine as draining in the API.
- Sends a drain signal over the engine WebSocket.
- The engine stops accepting new tasks and waits for in-flight work to finish.
- When all workers are idle, the engine shuts down.
The engine must be connected (online WebSocket). If it is offline, the API returns an error and the status does not change. If the drain signal cannot be sent, the API puts the previous status back and returns an error that says drain not sent.
Use drain before maintenance or when you want a clean shutdown without cutting off running tasks.
1curl -X POST "https://api.inference.sh/engines/eng_abc123/drain" \2 -H "Authorization: Bearer inf_your_key"While draining, new tasks routed to that engine are rejected with reason engine_draining.
Update engine binary
POST /engines/{id}/update
Triggers a safe engine restart on a connected private engine, toward a release target:
- The API sends an update signal over the engine WebSocket, naming the target.
- The engine resolves the target on
https://dist.inference.sh/engine/(same OS/arch). If it names a different binary, the engine downloads and swaps it before restarting. It keeps the current binary, and logs why, when it can't replace itself: a development build, an install a package manager owns, or a directory the engine's user can't write to. - The engine drains in-flight tasks and restarts the process (re-exec) after workers are idle — even when already on the latest version.
The engine reports what it did before it drains, and the engine's last_update records it (engine v1.21.20 and later):
| Field | Type | Description |
|---|---|---|
state | string | See below |
target | string | Engines: what was asked for (stable, canary or a version). Empty for remotes, which always take the latest release. |
from | string | Version the machine ran when asked |
to | string | Version it installs or was already on, when known |
error | string | Why, for refused and failed |
at | string | When state was reached |
| State | Meaning |
|---|---|
requested | Sent; nothing has answered yet. Engines before v1.21.20 never answer, so theirs stays here. |
installing | A different release is being installed; the machine finishes its running work and restarts on it |
installed | The machine reconnected on to |
current | Already on to; nothing installed |
refused | The binary can't replace itself: a development build, a package manager's install, or a directory the machine's user can't write to. error says what to do on the machine. |
failed | The release couldn't be checked, downloaded or installed. error says why. The machine keeps its version. |
The engine restarts whatever the state; refused and failed restart it on its current binary. The engine page shows it under last update.
This is the API equivalent of the web app's Update action on Engines or running engine update on the host. Use it for binary upgrades, switching release channels, or a clean restart without killing running tasks.
Request
Optional JSON body:
| Field | Type | Required | Description |
|---|---|---|---|
version | string | No | stable (default), canary, or a version such as v1.9.3. Anything else returns 400 and is never sent to the engine. |
After an update to canary or a specific version, the engine is pinned to it and reports that in engine_pin. An update to stable lifts the pin, and installs the stable head even when it sorts below the running canary build. Auto-update at engine start only moves forward.
1# stable (same as no body)2curl -X POST "https://api.inference.sh/engines/eng_abc123/update" \3 -H "Authorization: Bearer inf_your_key"45# canary6curl -X POST "https://api.inference.sh/engines/eng_abc123/update" \7 -H "Authorization: Bearer inf_your_key" \8 -H "Content-Type: application/json" \9 -d '{"version":"canary"}'The engine must be online. If the update signal cannot be sent, the request returns an error that says update not sent, and last_update is failed. On hosts you manage directly, you can also update with the engine CLI — see Installing the engine.
Extend cloud engine duration
POST /engines/{id}/extend
Adds runtime to a cloud-provisioned engine (Shadeform instance) before its auto-delete threshold. Requires engines:write and rent_engines, as for create. Your workspace balance is debited in microcents at hourly_price × additional_hours (with hourly_price in cents per hour).
Request
| Field | Type | Required | Description |
|---|---|---|---|
additional_hours | number | Yes | Hours to add (must be > 0) |
The engine must have an active instance with auto_delete.date_threshold and a positive hourly_price synced from the provider.
1curl -X POST "https://api.inference.sh/engines/eng_abc123/extend" \2 -H "Authorization: Bearer inf_your_key" \3 -H "Content-Type: application/json" \4 -d '{"additional_hours": 3}'Returns the updated engine DTO with a new instance auto_delete threshold. The new threshold cannot be more than 30 days ahead of the request (same cap as create); otherwise the API returns 400 with code extend_failed.
Other errors use 400 with code extend_failed when the instance cannot be extended (for example, missing threshold or price).
Self-hosted engines on your own hardware do not use this endpoint — use Update engine binary or restart the service on the host.
Stop engine
POST /engines/{id}/stop
Stops a managed engine instance. If the engine is connected, it receives a graceful stop signal, finishes in-flight tasks, then terminates (including cloud instance teardown when applicable). If the engine is offline, or the stop signal cannot be sent, the API finalizes the stop immediately.
For cloud-provisioned engines with a prepaid reservation, finalize also credits unused prepaid time minus elapsed usage (see Create cloud engine — Balance charges). Self-hosted engines on your own hardware are not billed through this path.
Restart engine
POST /engines/{id}/restart
Restarts the underlying cloud instance (Shadeform) for engines provisioned through inference.sh. For self-hosted engines on your own hardware, use update or restart the inferencesh-engine process on the host.
Rename engine
PATCH /engines/{id} (or POST /engines/{id})
Requires engines:write. The name is the only field you write on an engine.
1curl -X PATCH "https://api.inference.sh/engines/eng_abc123" \2 -H "Authorization: Bearer inf_your_key" \3 -H "Content-Type: application/json" \4 -d '{"name":"gpu-box-1"}'Set engine visibility
POST /engines/{id}/visibility
Requires engines:write. Body: {"visibility": "team"}. Engines take only private and team; any other value returns 400 visibility_not_allowed (see Allowed visibility per resource). The engine's workers get the same visibility.
Transfer engine
POST /engines/{id}/transfer
Requires engines:write. Body: {"team_id": "team_xyz"}. Moves the engine to another workspace you belong to. Its creator or a workspace admin may transfer it.
Reset engine identity
POST /engines/{id}/identity/reset
For a self-hosted engine whose host was lost or re-imaged. The API clears the engine's pinned signing key, closes its connections, and returns a new one-time enrollment token to run engine setup --token with on the next host. The engine record stays the same.
Only a workspace owner or admin may call it, from their own sign-in in the web app with a fresh step-up check. An API key is refused with 403. The reset is audited.
| Field | Type | Description |
|---|---|---|
engine_id | string | The engine |
token | string | One-time enrollment token (infen-…) |
expires_at | string | When the token stops working |
Set capacity policy
POST /engines/{id}/capacity
Sets how the API uses the engine's room. Requires engines:write and write access to the engine. The engine itself is told nothing except its CPU slots, which apply at its next register. A field you leave out keeps the default; {} clears the policy.
| Field | Type | Description |
|---|---|---|
sandboxes | boolean | false keeps new sandboxes off the engine. Sandboxes already on it run until they stop |
cpu_overcommit | number | Multiplies the engine's allocatable CPUs for sandbox placement (2 gives out twice its CPUs). From 1 to 8. Unset uses the platform default |
memory_overcommit | number | The same for memory. From 1 to 8 |
cpu_slots | integer | CPU app worker slots the engine gets at its next register, in place of workers.cpu.count in engine.yml. From 0 to 1024 |
A value out of range returns 400 validation_error (for example cpu_overcommit is from 1 to 8). An unknown field returns 400 invalid_request, so a typo cannot clear the stored policy. The response is the engine, with the new capacity_policy.
1curl -X POST "https://api.inference.sh/engines/eng_abc123/capacity" \2 -H "Authorization: Bearer inf_your_key" \3 -H "Content-Type: application/json" \4 -d '{"sandboxes": false, "cpu_slots": 4}'EngineCapacityPolicy is in @inferencesh/sdk ≥ v0.39.1 and inferencesh ≥ v0.39.1.
Engine WebSocket
The engine keeps a WebSocket open at /ws/engines/{id} for dispatch, signals, telemetry and heartbeats. This socket, like /ws/remotes/{id}, is for daemons only. The handshake returns 403 forbidden when the request has an Origin header (this socket is for daemons, not browser pages) or was signed in with the browser session cookie (this socket takes an API key or the daemon's own token, not a browser session).
JavaScript SDK
1import { inference } from '@inferencesh/sdk';23const client = inference({ apiKey: 'inf_your_key' });45await client.engines.drain('eng_abc123');6await client.engines.updateBinary('eng_abc123'); // stable; POST /engines/{id}/update7await client.engines.updateBinary('eng_abc123', 'canary'); // or 'v1.9.3'8const { data: heads } = await client.engines.releases(); // GET /engines/releases9await client.engines.stop('eng_abc123');10await client.engines.restart('eng_abc123');11// POST /engines/{id}/extend — pass { additional_hours } in the request body (REST or HttpClient)client.engines also exposes list, get, create, update (rename), updateVisibility, transferOwnership, delete, and stream. Call the capacity route with REST. The release target on updateBinary and releases() need @inferencesh/sdk ≥ v0.29.0.
Related
| Guide | Topic |
|---|---|
| Workers | Cloud vs private workers |
| Installing the engine | Host setup and manual upgrades |
| Using private workers | Routing tasks with infra: "private" |
| Instance types | GPU catalog for cloud-provisioned engines |