Skip to content

Environment Variables

Device Agent reads process environment variables and then tries to load .env at startup for deployment, secrets, and environment-specific values. Supported fields are written into .device_agent/config.json; startup-only values such as HTTP binding, database, A2A identity, and extra IM channels are not.

In development, .env is usually in the repository root. The installed binary reads .env from the install directory. On macOS/Linux, the default path is ${XDG_DATA_HOME:-$HOME/.local/share}/device-agent/current/.env. To affect only one startup, pass the variables directly before device-agent.

bash
ENV_FILE="${XDG_DATA_HOME:-$HOME/.local/share}/device-agent/current/.env"
touch "$ENV_FILE"

MQTT

VariableNotes
MQTT_BROKER_URLMQTT broker URL used by the gateway and device-side clients, such as mqtt://localhost:1883.
VITE_MQTT_WS_URLMQTT broker WebSocket URL used by the browser, such as ws://localhost:8083/mqtt.
MQTT_CLIENT_IDClient ID used by the gateway MQTT connection.
MQTT_PROTOCOL_VERSIONMQTT protocol version. Supports 4 and 5.
MQTT_KEEPALIVE_SECONDS / MQTT_KEEP_ALIVE_SECONDSKeep Alive interval.
MQTT_CONNECT_TIMEOUT_MSConnection timeout.
MQTT_AUTO_RECONNECTWhether to reconnect automatically.
MQTT_RECONNECT_PERIOD_MSReconnect interval.
MQTT_CLEAN_STARTWhether to use Clean Start.
MQTT_SESSION_EXPIRY_INTERVAL_SECONDSMQTT 5 session expiry interval.
MQTT_USERNAME / MQTT_PASSWORDCommon MQTT credentials for gateway and device-side clients.
VITE_MQTT_USERNAME / VITE_MQTT_PASSWORDBrowser-side MQTT credentials. Use only when the browser must connect directly to the broker.

TLS variables:

VariableNotes
MQTT_TLS_ENABLEDEnable MQTT TLS.
MQTT_TLS_INSECURESet to true to disable server certificate verification.
MQTT_TLS_REJECT_UNAUTHORIZEDWhether to verify the server certificate.
MQTT_TLS_CA_FILECA certificate path.
MQTT_TLS_CERT_FILEClient certificate path.
MQTT_TLS_KEY_FILEClient private key path.
MQTT_TLS_KEY_PASSPHRASEClient private key passphrase.
MQTT_TLS_SERVER_NAMETLS Server Name.

Topic template variables:

bash
MQTT_TOPIC_PRODUCT_IN=device-agent/{productId}/in
MQTT_TOPIC_PRODUCT_OUT=device-agent/{productId}/out
MQTT_TOPIC_DEVICE_IN=device-agent/{productId}/device/{deviceId}/in
MQTT_TOPIC_DEVICE_OUT=device-agent/{productId}/device/{deviceId}/out
MQTT_TOPIC_DEVICE_COMMAND=device-agent/{productId}/device/{deviceId}/commands
MQTT_TOPIC_DEVICE_RESPONSE=device-agent/{productId}/device/{deviceId}/responses
MQTT_TOPIC_TELEMETRY=v1/{productId}/{deviceId}/telemetry
MQTT_TOPIC_EVENT=v1/{productId}/{deviceId}/event
MQTT_TOPIC_NTP_REQUEST=device-agent/{productId}/device/{deviceId}/ntp/request
MQTT_TOPIC_NTP_RESPONSE=device-agent/{productId}/device/{deviceId}/ntp/response

Topic templates must keep the {productId} and {deviceId} placeholders. See MQTT Access for topics and payloads.

Models and Vision

VariableNotes
LLM_PROVIDERPrimary agent model provider.
LLM_MODELPrimary agent model name.
LLM_BASE_URLCustom model service URL, commonly used for OpenAI-compatible endpoints or local model services.
LLM_API_KEYGeneric model API key.
OPENAI_API_KEY / ANTHROPIC_API_KEY / KIMI_API_KEY / QWEN_API_KEYProvider-specific API keys.
OPENAI_CODEX_AUTH_FILECodex auth file path for the openai-codex provider.
OPENAI_CODEX_ACCESS_TOKENAccess token for the openai-codex provider.
AGENT_MAX_ITERATIONSMaximum iterations for one agent task.
VISION_ENABLEDWhether vision is enabled.
VISION_PROVIDERVision provider. Supports auto and dashscope.
VISION_MODELVision model name.
VISION_API_KEYVision model API key.
VISION_TIMEOUT_MSVision analysis timeout.

With VISION_PROVIDER=auto, Device Agent tries to reuse the primary agent model when it supports image input. To use a separate vision model, set VISION_PROVIDER=dashscope, VISION_MODEL, and VISION_API_KEY.

HTTP, Frontend, and Data Storage

VariableNotes
AGENT_GATEWAY_HTTP_HOSTConsole and HTTP API bind address. Defaults to 127.0.0.1. Use 0.0.0.0 for server IP or LAN access.
AGENT_GATEWAY_HTTP_PORTConsole and HTTP API port. Defaults to 3000.
AGENT_GATEWAY_HTTP_TLS_ENABLEDWhether to serve the console and HTTP API over direct HTTPS. If omitted, providing both certificate and key files enables TLS.
AGENT_GATEWAY_HTTP_TLS_CERT_FILE / AGENT_GATEWAY_HTTP_TLS_KEY_FILETLS certificate and private key paths for direct HTTPS. Relative paths are resolved from the workspace root.
AGENT_GATEWAY_HTTP_TLS_PASSPHRASETLS private key passphrase for direct HTTPS.
VITE_API_BASE_URLFrontend API base URL. Usually not needed when same-origin proxying is used.
VITE_DEVICE_AGENT_PENDING_TIMEOUT_MSTimeout for console Device Agent creation or pending responses.
DATABASE_DRIVERData storage driver. The default uses local storage; set postgres to use PostgreSQL.
DATABASE_URLPostgreSQL connection URL. Required only when DATABASE_DRIVER=postgres.
WEBHOOK_CREDENTIAL_MASTER_KEYRequired 32-byte Base64 key for PostgreSQL deployments. Use the same value on every Gateway.

Frontend variables are read by the frontend dev server or build process. Restart the frontend service or rebuild after changing them.

Enable Direct HTTPS

Set a certificate and matching private key, then restart Device Agent:

bash
AGENT_GATEWAY_HTTP_HOST=0.0.0.0
AGENT_GATEWAY_HTTP_PORT=3000
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

The console and HTTP API then use https://<host>:3000. Certificate and key must be configured together. Relative paths are resolved from the workspace or installation root. Providing both files also enables HTTPS when AGENT_GATEWAY_HTTP_TLS_ENABLED is omitted; setting it to false keeps HTTP enabled instead. HTTPS encrypts traffic but does not add user authentication, so restrict access to a trusted network or an authenticated gateway.

See Installation for browser and certificate verification steps.

Configure the Webhook Key

For PostgreSQL, generate WEBHOOK_CREDENTIAL_MASTER_KEY once with openssl rand -base64 32, use the same value on every Gateway, and keep a secure backup. Do not rotate it casually.

SQLite deployments do not require this variable. See Webhook for connection setup.

Voice

VariableNotes
VOICE_ENABLEDWhether the voice channel is enabled.
VOICE_HOSTVoice service bind address. Defaults to 127.0.0.1; use 0.0.0.0 for LAN or server access.
VOICE_PORTVoice service bind port. Defaults to 3001.
VITE_ASR_SAMPLE_RATEASR sample rate used by browser audio capture.
VOICE_REGIONVoice region. Supports cn, us, eu, and global.
VOICE_TLS_ENABLEDWhether voice service TLS is enabled.
VOICE_TLS_CERT_FILE / VOICE_TLS_KEY_FILEVoice service TLS certificate and private key paths.
VOICE_TLS_PASSPHRASEVoice service TLS private key passphrase.

Speech provider variables:

ProviderVariables
VolcengineVOLCENGINE_SPEECH_APP_ID, VOLCENGINE_SPEECH_ACCESS_KEY, VOLCENGINE_ASR_RESOURCE_ID, VOLCENGINE_ASR_LANGUAGE, VOLCENGINE_TTS_RESOURCE_ID, VOLCENGINE_TTS_VOICE, VOLCENGINE_TTS_VOICES, VOLCENGINE_TTS_EXPLICIT_LANGUAGE, VOLCENGINE_TTS_SAMPLE_RATE
Alibaba Cloud DashScopeALIYUN_DASHSCOPE_API_KEY, ALIYUN_ASR_MODEL, ALIYUN_ASR_LANGUAGE, ALIYUN_TTS_MODEL, ALIYUN_TTS_VOICE, ALIYUN_TTS_VOICES, ALIYUN_TTS_SAMPLE_RATE
AWSAWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, AWS_REGION, AWS_TRANSCRIBE_LANGUAGE_CODE, AWS_POLLY_VOICE, AWS_POLLY_SAMPLE_RATE
ElevenLabsELEVENLABS_API_KEY, ELEVENLABS_API_ENDPOINT, ELEVENLABS_ASR_MODEL_ID, ELEVENLABS_ASR_LANGUAGE, ELEVENLABS_TTS_MODEL_ID, ELEVENLABS_TTS_VOICE, ELEVENLABS_TTS_VOICES, ELEVENLABS_TTS_SAMPLE_RATE

For voice configuration details, see Voice Configuration. For usage flow, see Voice Interaction.

IM

These channels can also be configured from the console settings page:

ChannelVariables
FeishuFEISHU_ENABLED, FEISHU_APP_ID, FEISHU_APP_SECRET, FEISHU_ENCRYPT_KEY, FEISHU_VERIFICATION_TOKEN, FEISHU_ALLOW_FROM
DingTalkDINGTALK_ENABLED, DINGTALK_CLIENT_ID, DINGTALK_CLIENT_SECRET, DINGTALK_ALLOW_FROM
DiscordDISCORD_ENABLED, DISCORD_BOT_TOKEN, DISCORD_ALLOW_FROM
TelegramTELEGRAM_ENABLED, TELEGRAM_BOT_TOKEN, TELEGRAM_ALLOW_FROM
SlackSLACK_ENABLED, SLACK_BOT_TOKEN, SLACK_APP_TOKEN, SLACK_SIGNING_SECRET, SLACK_ALLOW_FROM, SLACK_CHANNEL_DIRECT_ENABLED

Additional IM channels are env-only and do not appear in the console settings page:

ChannelVariables
WhatsAppWHATSAPP_ENABLED, WHATSAPP_BRIDGE_URL, WHATSAPP_BRIDGE_TOKEN, WHATSAPP_ALLOW_FROM
QQQQ_ENABLED, QQ_APP_ID, QQ_APP_SECRET, QQ_TOKEN, QQ_SANDBOX, QQ_ALLOW_FROM
MatrixMATRIX_ENABLED, MATRIX_HOMESERVER_URL, MATRIX_ACCESS_TOKEN, MATRIX_AUTOJOIN, MATRIX_ALLOW_FROM
MoChatMOCHAT_ENABLED, MOCHAT_SERVER_URL, MOCHAT_TOKEN, MOCHAT_BOT_NAME, MOCHAT_ALLOW_FROM
EmailEMAIL_ENABLED, EMAIL_IMAP_HOST, EMAIL_IMAP_PORT, EMAIL_IMAP_USER, EMAIL_IMAP_PASSWORD, EMAIL_IMAP_TLS, EMAIL_SMTP_HOST, EMAIL_SMTP_PORT, EMAIL_SMTP_USER, EMAIL_SMTP_PASSWORD, EMAIL_SMTP_TLS, EMAIL_FROM_ADDRESS, EMAIL_POLL_INTERVAL_MS, EMAIL_ALLOW_FROM

See IM Access for platform-specific setup.

Logging

VariableNotes
LOG_LEVELLog level. Supports debug, info, warn, and error.
LOG_CONSOLE_ENABLEDWhether to write logs to the console.
LOG_FILE_ENABLEDWhether to write logs to files.
LOG_DIRLog directory. Relative paths resolve under the runtime home.
LOG_MAX_SIZE_MBMaximum size of one log file.
LOG_RETENTION_DAYSLog retention days.
LOG_MAX_TOTAL_SIZE_MBMaximum total log file size.
LOG_TIMEZONEFile log timestamp timezone: system or utc.

See Logs for logging usage.

Tool Permissions

VariableNotes
ENABLE_TOOL_EDITOR_MUTATIONSReapplies and persists the tool editor save/delete permission on every startup.
ENABLE_FILE_WRITE_TOOLReapplies and persists the write_file tool permission on every startup.
ENABLE_EXECUTE_COMMAND_TOOLReapplies and persists the execute_command tool permission on every startup.
ALLOWED_EXEC_COMMAND_PREFIXESReapplies and persists the allowed command prefixes on every startup. An empty value clears the allowlist.
DANGEROUSLY_BYPASS_TOOL_PERMISSIONSServer-only startup flag. It is not written to config.json or exposed in the console. Set to true to bypass file-write approvals, command approvals and allowlists, shell safety checks, and tool editor mutation gates. This is not a sandbox: bypassed writes can modify executable code or tool extensions, and commands run with the Gateway process's host permissions. Use it only when the Agent, workspace, and all Gateway secrets are trusted.

A2A

VariableNotes
A2A_ORG_ID / A2A_UNIT_IDOrganization and unit identity used for A2A registration and discovery. Both default to default.

See A2A for A2A usage.