Using Private Workers

Run tasks on your own hardware.


In the workspace

Toggle to "Private" when running an app:

code
1Run on: [○ Cloud] [● Private]

Via API

python
1result = client.run({2    "app": "my-app",3    "input": {...},4    "infra": "private"5})

Use infra: "private_first" when you want private workers when available, with automatic cloud fallback:

python
1result = client.run({2    "app": "my-app",3    "input": {...},4    "infra": "private_first"5})

Specific workers

Target exact workers:

python
1result = client.run({2    "app": "my-app",3    "input": {...},4    "infra": "private",5    "workers": ["my-server-gpu-0"]6})

Every ID must be a worker of your workspace. An unknown ID, or another workspace's, is refused at submit with 400 validation_error (workers not found in team <username>: …). If none of the listed workers is online, the task fails with none of the listed workers is online.


Agents on private

An agent's app tools run as tasks. Whoever runs the agent chooses where those tasks go, with infra on the run request:

bash
1curl -X POST https://api.inference.sh/agents/run \2  -H "Authorization: Bearer inf_your_key" \3  -H "Content-Type: application/json" \4  -d '{"agent":"my-team/my-agent","input":{"text":"upscale this image"},"infra":"private_first"}'
ValueWhere the agent's app tasks run
cloudCloud workers. The default
privateYour workspace's own workers only
private_firstYour own workers when one can take the task, cloud workers otherwise
  • It is kept on the chat. Later messages in the same chat use it without sending it again. A request that names another value replaces it. Chat settings change it too.
  • It covers every app the agent runs in that chat: the tools it lists, the apps it finds and runs by name, and the app tools of its sub-agents.
  • It is not part of the agent. An agent's author cannot set it, so a shared or published agent never forces private on a workspace with no engines.
  • Embeds, triggers and channels start on the cloud. A visitor of a public embed cannot set it. For a chat a trigger or channel started, set it in chat settings.

infra does not change where the agent's model runs, or where a sandbox its sandbox_create tool makes is placed.

See Agents API — Run agent.


Sandboxes on private

A managed sandbox can run on your own engine. The engine must host sandboxes: it reports the sandboxes capability. engine setup installs boxd, which runs the sandbox VMs, for the sandbox role on a Linux host with KVM; --roles sandbox asks for the role.

Set infra when you create the sandbox:

bash
1curl -X POST https://api.inference.sh/sandboxes \2  -H "Authorization: Bearer inf_your_key" \3  -H "Content-Type: application/json" \4  -d '{"name":"dev-box","infra":"private"}'
ValueWhere the sandbox is placed
cloudPlatform engines. The default
privateYour workspace's engines only
private_firstYour engines when one has room, platform engines otherwise

On your own engine a sandbox costs nothing and starts with no balance. Plan limits and the purchase condition apply as on the cloud.

See Sandboxes API — Where a sandbox runs.


Monitoring

In the sidebar, open Resources → Engines (/engines) to check status:

  • Online/offline status
  • Resource usage
  • Running tasks
  • Drain / Update — graceful maintenance (see Updating)

To drain or upgrade an engine without killing in-flight tasks, see Managing engines.

Use Drain before maintenance or Update for a safe binary upgrade (in-flight tasks finish first). The same operations are available via the Engines API or client.engines.drain() / client.engines.updateBinary() in the JavaScript SDK.


Caching

The engine caches:

  • App code
  • Downloaded models
  • Container images

Second runs are much faster.


Next

GuideTopic
Managing enginesDrain, update, and restart
ConfigurationEngine and worker settings
Why private?When to use your own hardware

→ Back to Docs

we use cookies

we use cookies to ensure you get the best experience on our website. for more information on how we use cookies, please see our cookie policy.

by clicking "accept", you agree to our use of cookies.
learn more.