# Installation

For local or single-instance use, install and start Device Agent, then open the Web console to create Device Agents and connect MQTT devices. For private enterprise production deployments at scale, see the [platform solution](./platform/overview.md) and [Deployment and Configuration](./platform/deployment.md).

## Where to Install

Device Agent supports macOS, Linux, and Windows. You can install it on a development computer, edge
gateway, Linux industrial computer, or private server. The environment needs access to your MQTT
Broker and LLM service, and the Web console port must be reachable. The default port is `3000`.

- Local evaluation: install it on your development computer and open `http://127.0.0.1:3000`.
- On-site runtime: install it on an edge gateway, Linux industrial computer, or private server close
  to the device network, then access the console from the server IP.

## Recommended Hardware

| Setup | CPU | Memory | Disk | Best for |
| --- | --- | --- | --- | --- |
| Minimum | 2 cores | 512 MB | 300 MB free | Local evaluation, demos, and small board deployments |
| Recommended | 2-4+ cores | 1 GB+ | 1 GB free | Long-running on-site runtime |

## Prerequisites

Device Agent connects to an MQTT Broker and an LLM service. Before installing, make sure you have:

- MQTT Broker endpoint and credentials
- LLM provider, model name, and API key
- Browser access to the Device Agent Web console port, `3000` by default

### Prepare an MQTT Broker

If you do not have an MQTT Broker yet, the fastest setup is to set `ZERO_EMQX_ENABLED=true` on first
startup. Device Agent creates a temporary Zero EMQX Broker and writes the MQTT settings. The broker
is powered by [EMQX Cloud](https://www.emqx.com/en/cloud), expires automatically, and is not intended
for long-term use. For other broker options, see
[MQTT Broker](./operate-reference/configuration/mqtt-broker.md).

### Prepare LLM Configuration

The quick start needs an LLM that supports tool calls. On first startup, set `LLM_PROVIDER`,
`LLM_MODEL`, and the matching API key; you can also fill these values after startup from
**Settings → Models** in the console. For more providers, fields, and local model options, see
[LLM Configuration](./operate-reference/configuration/model-config.md).

## Download and Install

### macOS and Linux

```bash
curl -fsSL https://emqx.sh/device-agent | sh
device-agent --version
```

### Windows PowerShell

```powershell
irm https://emqx.sh/device-agent.ps1 | iex
device-agent --version
```

### Docker

```bash
docker pull emqx/device-agent:latest

docker run -d --name device-agent --restart unless-stopped \
  -p 127.0.0.1:3000:3000 -p 127.0.0.1:3001:3001 \
  -e AGENT_GATEWAY_HTTP_HOST=0.0.0.0 -e VOICE_HOST=0.0.0.0 \
  -v device-agent-data:/home/device-agent/.device_agent \
  emqx/device-agent:latest
```

## Configure

For a first run, set startup variables directly before `device-agent`:

```bash
ZERO_EMQX_ENABLED=true \
LLM_PROVIDER=openai \
LLM_MODEL=gpt-5.5 \
OPENAI_API_KEY=sk-... \
device-agent
```

When using an existing MQTT Broker, replace `ZERO_EMQX_ENABLED=true` with `MQTT_BROKER_URL`,
`VITE_MQTT_WS_URL`, `MQTT_USERNAME`, and `MQTT_PASSWORD`. For long-running deployments, use `.env` or
`config.json`; see [Environment Variables](./operate-reference/configuration/environment-variables.md)
for paths and [MQTT Broker](./operate-reference/configuration/mqtt-broker.md) for broker examples.

## Start and Verify

If you did not start Device Agent in the previous step, run:

```bash
device-agent
```

Then open the Web console:

```text
http://127.0.0.1:3000
```

To access the Web console from a server IP or LAN address, set the HTTP host. `3000` is the default
port; replace it only when you need a different port:

```bash
AGENT_GATEWAY_HTTP_HOST=0.0.0.0
AGENT_GATEWAY_HTTP_PORT=3000
```

If you can enter the device agent creation flow and the MQTT connection is healthy, the installation is ready.

## Enable HTTPS

Configure the certificate in the installation `.env`, then restart Device Agent:

```bash
AGENT_GATEWAY_HTTP_TLS_ENABLED=true
AGENT_GATEWAY_HTTP_TLS_CERT_FILE=/etc/device-agent/fullchain.pem
AGENT_GATEWAY_HTTP_TLS_KEY_FILE=/etc/device-agent/privkey.pem
```

Open `https://<server-host>:3000`. For a private CA, verify with its CA file:

```bash
curl --cacert /path/to/ca.pem https://<server-host>:3000/api/health
```

Public or shared networks also require an authenticated reverse proxy or VPN. If the console connects directly to MQTT or voice services, use `wss://` for those endpoints. See [Environment Variables](./operate-reference/configuration/environment-variables.md#enable-direct-https) for other options.

## Update

macOS, Linux, and Windows:

```bash
device-agent update
```

Restart Device Agent after updating.

When upgrading from 0.3.x to 0.4.0 with a shared database, stop every older Gateway before starting 0.4.0. Do not run both versions during a rolling update: older Gateways do not coordinate with the new scheduled-task runner and may execute the same task more than once.

## Uninstall Device Agent

Stop Device Agent first.

### macOS and Linux

Remove the install directory and launcher:

```bash
rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/device-agent"
rm -f ~/.local/bin/device-agent
```

To also remove runtime config and local data:

```bash
rm -rf ~/.device_agent
```

For custom installs: remove the install directory set by
`DEVICE_AGENT_INSTALL_DIR` and the `device-agent` launcher under
`DEVICE_AGENT_BIN_DIR`.

### Windows PowerShell

Remove the install directory and launcher:

```powershell
$root = Join-Path $env:LOCALAPPDATA "Programs\DeviceAgent"
Remove-Item -LiteralPath $root -Recurse -Force
```

To also remove runtime config and local data:

```powershell
Remove-Item -LiteralPath (Join-Path $HOME ".device_agent") -Recurse -Force
```

For custom installs: remove the install directory set by
`DEVICE_AGENT_INSTALL_DIR` and the `device-agent.cmd` launcher under
`DEVICE_AGENT_BIN_DIR`.

## Next Steps

- Read [Quick Start](./quick-start/quick-start.md) to complete your first device agent experience.
- Go to [Define a Device Agent](./usage/create-agent.md) to define device intelligence in natural language.
- See [MQTT Access](./device-access/mqtt.md) to connect real devices to Device Agent.
